[{"id":21300,"web_url":"https://patchwork.libcamera.org/comment/21300/","msgid":"<YaQArIldXWAfG/QM@pendragon.ideasonboard.com>","date":"2021-11-28T22:20:28","subject":"Re: [libcamera-devel] [PATCH 3/5] libcamera: ipu3-cio2: Discover\n\tVCMs 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, Nov 26, 2021 at 12:31:16AM +0000, Daniel Scally wrote:\n> Rather than attempting to discover VCMs via model name matching we\n> should follow the ancillary links that define the relationship\n> between the two devices to locate any entities linked to the sensor.\n> Where we have linked entities with the function MEDIA_ENT_F_LENS we\n> can then create an instance of CameraLens to represent it.\n> \n> Signed-off-by: Daniel Scally <djrscally@gmail.com>\n\nGiven that Han-lin's patch that add model-based matching hasn't been\nmerged yet, I think this should be rebased on top of the master branch\ndirectly. There's no need to merge model-based matching to replace it\nimmediately after.\n\n> ---\n> \n> Alternatively rather than replace the matching on model names we could try\n> the ancillary links first and then simply guard the existing model matching\n> with an if (!lens_) ...\n\nI think ancillary links are good enough, there's no need for model-based\nmatching.\n\n>  src/libcamera/pipeline/ipu3/cio2.cpp | 45 +++++++++++++++-------------\n>  1 file changed, 25 insertions(+), 20 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> index 59b2f586..169e7b54 100644\n> --- a/src/libcamera/pipeline/ipu3/cio2.cpp\n> +++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n> @@ -161,30 +161,35 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n>  \t}\n>  \n>  \t/*\n> -\t * \\todo Read the lens model from the sensor itself or from a device\n> -\t * database. For now use default values taken from ChromeOS database.\n> +\t * Sensors sometimes have ancillary devices such as a Lens or Flash\n> +\t * that could be linked to the MediaEntity - search for and handle\n> +\t * any such device (for now, we can only handle MEDIA_ENT_F_LENS)\n> +\t *\n> +\t * \\todo Handle MEDIA_ENT_F_FLASH too.\n>  \t */\n> -\tstatic std::unordered_map<std::string, std::string> sensorLens = {\n> -\t\t{ \"ov13858\", \"dw9714\" },\n> -\t\t{ \"imx258\", \"dw9807\" },\n> -\t\t{ \"imx355\", \"ak7375\" }\n> -\t};\n> -\n> -\tauto it = sensorLens.find(sensor_->model());\n> -\tif (it != sensorLens.end()) {\n> -\t\tconst std::vector<MediaEntity *> &entities = media->entities();\n> -\t\tfor (auto ent : entities) {\n> -\t\t\tif (ent->function() == MEDIA_ENT_F_LENS) {\n> -\t\t\t\tlens_ = std::make_unique<CameraLens>(ent);\n> +\tconst std::vector<MediaLink *> &ancillary_links = sensorEntity->ancillary_links();\n> +\tif (!ancillary_links.empty()) {\n> +\t\tfor (auto it : ancillary_links) {\n> +\t\t\tMediaEntity *ancillaryEntity = it->ancillary();\n> +\n> +\t\t\tswitch (ancillaryEntity->function()) {\n> +\t\t\tcase MEDIA_ENT_F_LENS:\n> +\t\t\t\tlens_ = std::make_unique<CameraLens>(ancillaryEntity);\n>  \t\t\t\tret = lens_->init();\n> -\t\t\t\tif (!ret && lens_->model() == it->second) {\n> -\t\t\t\t\tbreak;\n> +\t\t\t\tif (ret) {\n> +\t\t\t\t\tLOG(IPU3, Error)\n> +\t\t\t\t\t\t<< \"Error during CameraLens init\";\n> +\t\t\t\t\treturn ret;\n>  \t\t\t\t}\n> -\t\t\t\tlens_.reset();\n> +\t\t\t\tbreak;\n> +\t\t\tcase MEDIA_ENT_F_FLASH:\n> +\t\t\t\tLOG(IPU3, Warning)\n> +\t\t\t\t\t<< \"Flash not yet supported\";\n> +\t\t\t\tbreak;\n> +\t\t\tdefault:\n> +\t\t\t\tLOG(IPU3, Warning)\n> +\t\t\t\t\t<< \"Unsupported entity function\";\n>  \t\t\t}\n\nCould we simplify the pipeline handlers a bit by moving at least the\nlookup of the VCM entity to the CameraSensor class ?\n\n> -\t\t\tif (!lens_)\n> -\t\t\t\tLOG(IPU3, Warning) << \"Lens device \"\n> -\t\t\t\t\t\t   << it->second << \" not found\";\n>  \t\t}\n>  \t}\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 EE0B8BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 28 Nov 2021 22:20:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 575596058C;\n\tSun, 28 Nov 2021 23:20:54 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B6F9604FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 28 Nov 2021 23:20:53 +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 B770AF1;\n\tSun, 28 Nov 2021 23:20:52 +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=\"Il0nBSYg\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638138052;\n\tbh=LUJVc3lj/Cp1qRYKnas3uJPDr1iq65CkRpmpBi4OneU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Il0nBSYg9E1lxYeLsdwiWcT+PQ9Ut21tOjO8fplOIzAFaNIZ5d/jr1ssS5Ndi5bT+\n\tGeIXLhVQ+4vECS38cp+oh5nFYUk/8irAvXUZAcd6zRQHFJitkofSvn5V0lJ0XE8efP\n\tzdFQ0mnKUQVmWeODFPpPY2qO0oVxWa/WPiW0bPyc=","Date":"Mon, 29 Nov 2021 00:20:28 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Daniel Scally <djrscally@gmail.com>","Message-ID":"<YaQArIldXWAfG/QM@pendragon.ideasonboard.com>","References":"<20211126003118.42356-1-djrscally@gmail.com>\n\t<20211126003118.42356-4-djrscally@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211126003118.42356-4-djrscally@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH 3/5] libcamera: ipu3-cio2: Discover\n\tVCMs 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":21304,"web_url":"https://patchwork.libcamera.org/comment/21304/","msgid":"<2e1fd1fc-96b0-df1c-6188-875e348c749a@gmail.com>","date":"2021-11-28T23:13:26","subject":"Re: [libcamera-devel] [PATCH 3/5] libcamera: ipu3-cio2: Discover\n\tVCMs through ancillary links","submitter":{"id":90,"url":"https://patchwork.libcamera.org/api/people/90/","name":"Daniel Scally","email":"djrscally@gmail.com"},"content":"Hi Laurent\n\nOn 28/11/2021 22:20, Laurent Pinchart wrote:\n> Hi Daniel,\n>\n> Thank you for the patch.\n>\n> On Fri, Nov 26, 2021 at 12:31:16AM +0000, Daniel Scally wrote:\n>> Rather than attempting to discover VCMs via model name matching we\n>> should follow the ancillary links that define the relationship\n>> between the two devices to locate any entities linked to the sensor.\n>> Where we have linked entities with the function MEDIA_ENT_F_LENS we\n>> can then create an instance of CameraLens to represent it.\n>>\n>> Signed-off-by: Daniel Scally <djrscally@gmail.com>\n> Given that Han-lin's patch that add model-based matching hasn't been\n> merged yet, I think this should be rebased on top of the master branch\n> directly. There's no need to merge model-based matching to replace it\n> immediately after.\n\n\nDid the patch introducing the CameraLens class get merged, then? I can\nrebase onto master in that case, no problem.\n\n>> ---\n>>\n>> Alternatively rather than replace the matching on model names we could try\n>> the ancillary links first and then simply guard the existing model matching\n>> with an if (!lens_) ...\n> I think ancillary links are good enough, there's no need for model-based\n> matching.\n\n\nRighto.\n\n>\n>>  src/libcamera/pipeline/ipu3/cio2.cpp | 45 +++++++++++++++-------------\n>>  1 file changed, 25 insertions(+), 20 deletions(-)\n>>\n>> diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n>> index 59b2f586..169e7b54 100644\n>> --- a/src/libcamera/pipeline/ipu3/cio2.cpp\n>> +++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n>> @@ -161,30 +161,35 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n>>  \t}\n>>  \n>>  \t/*\n>> -\t * \\todo Read the lens model from the sensor itself or from a device\n>> -\t * database. For now use default values taken from ChromeOS database.\n>> +\t * Sensors sometimes have ancillary devices such as a Lens or Flash\n>> +\t * that could be linked to the MediaEntity - search for and handle\n>> +\t * any such device (for now, we can only handle MEDIA_ENT_F_LENS)\n>> +\t *\n>> +\t * \\todo Handle MEDIA_ENT_F_FLASH too.\n>>  \t */\n>> -\tstatic std::unordered_map<std::string, std::string> sensorLens = {\n>> -\t\t{ \"ov13858\", \"dw9714\" },\n>> -\t\t{ \"imx258\", \"dw9807\" },\n>> -\t\t{ \"imx355\", \"ak7375\" }\n>> -\t};\n>> -\n>> -\tauto it = sensorLens.find(sensor_->model());\n>> -\tif (it != sensorLens.end()) {\n>> -\t\tconst std::vector<MediaEntity *> &entities = media->entities();\n>> -\t\tfor (auto ent : entities) {\n>> -\t\t\tif (ent->function() == MEDIA_ENT_F_LENS) {\n>> -\t\t\t\tlens_ = std::make_unique<CameraLens>(ent);\n>> +\tconst std::vector<MediaLink *> &ancillary_links = sensorEntity->ancillary_links();\n>> +\tif (!ancillary_links.empty()) {\n>> +\t\tfor (auto it : ancillary_links) {\n>> +\t\t\tMediaEntity *ancillaryEntity = it->ancillary();\n>> +\n>> +\t\t\tswitch (ancillaryEntity->function()) {\n>> +\t\t\tcase MEDIA_ENT_F_LENS:\n>> +\t\t\t\tlens_ = std::make_unique<CameraLens>(ancillaryEntity);\n>>  \t\t\t\tret = lens_->init();\n>> -\t\t\t\tif (!ret && lens_->model() == it->second) {\n>> -\t\t\t\t\tbreak;\n>> +\t\t\t\tif (ret) {\n>> +\t\t\t\t\tLOG(IPU3, Error)\n>> +\t\t\t\t\t\t<< \"Error during CameraLens init\";\n>> +\t\t\t\t\treturn ret;\n>>  \t\t\t\t}\n>> -\t\t\t\tlens_.reset();\n>> +\t\t\t\tbreak;\n>> +\t\t\tcase MEDIA_ENT_F_FLASH:\n>> +\t\t\t\tLOG(IPU3, Warning)\n>> +\t\t\t\t\t<< \"Flash not yet supported\";\n>> +\t\t\t\tbreak;\n>> +\t\t\tdefault:\n>> +\t\t\t\tLOG(IPU3, Warning)\n>> +\t\t\t\t\t<< \"Unsupported entity function\";\n>>  \t\t\t}\n> Could we simplify the pipeline handlers a bit by moving at least the\n> lookup of the VCM entity to the CameraSensor class ?\n\n\nSure; I actually moved it to ::init() now, that sound ok?\n\n>> -\t\t\tif (!lens_)\n>> -\t\t\t\tLOG(IPU3, Warning) << \"Lens device \"\n>> -\t\t\t\t\t\t   << it->second << \" not found\";\n>>  \t\t}\n>>  \t}\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 662E7BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 28 Nov 2021 23:13:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9CF296057D;\n\tMon, 29 Nov 2021 00:13:29 +0100 (CET)","from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com\n\t[IPv6:2a00:1450:4864:20::42f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2FEE76011D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Nov 2021 00:13:28 +0100 (CET)","by mail-wr1-x42f.google.com with SMTP id u1so32609398wru.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 28 Nov 2021 15:13:28 -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\tg19sm18693210wmg.12.2021.11.28.15.13.26\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tSun, 28 Nov 2021 15:13:27 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"PbOS85Tw\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=subject:to:cc:references:from:message-id:date:user-agent\n\t:mime-version:in-reply-to:content-transfer-encoding:content-language; \n\tbh=fJ8K1ucmcv/x/s2p/Od1aLsJComjihrtWO0M4g+Ckwg=;\n\tb=PbOS85TwAWT2WEFvAaIJG2h0O31uykW+CXGiyQEzuNG95PMtvaES1KnLpiryGK9Aa4\n\tp5YX8ljdbxG+xwkyku7ezdH1m6pp2emt+Gj/h7eYCN6SdDz8wOusAd+A1F42c1dsenCN\n\t5Gb23s9VVFP9xTbu8Ssx9sAC/BKKL3aHMoAMNemzgt3Bl9yvsajWlei0Ym27iiGHg6vF\n\tYEGcO1IHaB19AVX+p22sENDD7cM99cPSj/+OV3J6nBbmY4gBxqWFPle0iiQaR81UyKLX\n\tgcRYZW/SuSL8QjlSK8HBDiEs1koOz6PBRsbzHgNyfeqo/LAO9eAPjK4PJoRbDpM87rlC\n\t4YCg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:subject:to:cc:references:from:message-id:date\n\t:user-agent:mime-version:in-reply-to:content-transfer-encoding\n\t:content-language;\n\tbh=fJ8K1ucmcv/x/s2p/Od1aLsJComjihrtWO0M4g+Ckwg=;\n\tb=KhBxbHIfumF0/SktEJlZeBpoF2ybaQtZsvaOLfjbSVBMunkC7rd17Nzgw8Ce/ZVMeZ\n\t6m3yr/dPNT+HgmqvZkkOots269cPk+CqmpEPxo6hq7hIt1cfastegxxpc10up2Sn3cDX\n\twzHVHHYdZpJH64aH4DX7Q8QN5bH9m1lbqGUb6KgrSZZdzdMx50F1eUcTVpkJb4g0JQ8J\n\t0yNt1S7iv1GizkBR01rVkBteFjnFzJPelDoElrbeb4S4hE4hNtFey9OBdhPY+MXSl0Tn\n\tv/UQe4AuEitCiBW4mlotHtDW7TuiltXf2tHwXFd4IpDPdRoZHRn1QAuVhx9BEPlE9WOf\n\tJnog==","X-Gm-Message-State":"AOAM532tLBWnzjp0lOyVrDC4rBXB0pCruH3DuAkRdTLufgvmC7AV7MRC\n\tnOI2bbiASfGTE5lBHja0A1+sFyR8nm8=","X-Google-Smtp-Source":"ABdhPJwmGGM+8mtWVk9dgEM4Gd8bcKJwh6/gjo6202ENGmqSFmfXCfGADhWeX0KqgLuuTsMe9pRSZA==","X-Received":"by 2002:adf:e8c9:: with SMTP id\n\tk9mr29107814wrn.603.1638141207834; \n\tSun, 28 Nov 2021 15:13:27 -0800 (PST)","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20211126003118.42356-1-djrscally@gmail.com>\n\t<20211126003118.42356-4-djrscally@gmail.com>\n\t<YaQArIldXWAfG/QM@pendragon.ideasonboard.com>","From":"Daniel Scally <djrscally@gmail.com>","Message-ID":"<2e1fd1fc-96b0-df1c-6188-875e348c749a@gmail.com>","Date":"Sun, 28 Nov 2021 23:13:26 +0000","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.14.0","MIME-Version":"1.0","In-Reply-To":"<YaQArIldXWAfG/QM@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"7bit","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH 3/5] libcamera: ipu3-cio2: Discover\n\tVCMs 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":21306,"web_url":"https://patchwork.libcamera.org/comment/21306/","msgid":"<YaQarm8cI70giybk@pendragon.ideasonboard.com>","date":"2021-11-29T00:11:26","subject":"Re: [libcamera-devel] [PATCH 3/5] libcamera: ipu3-cio2: Discover\n\tVCMs 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\nOn Sun, Nov 28, 2021 at 11:13:26PM +0000, Daniel Scally wrote:\n> On 28/11/2021 22:20, Laurent Pinchart wrote:\n> > On Fri, Nov 26, 2021 at 12:31:16AM +0000, Daniel Scally wrote:\n> >> Rather than attempting to discover VCMs via model name matching we\n> >> should follow the ancillary links that define the relationship\n> >> between the two devices to locate any entities linked to the sensor.\n> >> Where we have linked entities with the function MEDIA_ENT_F_LENS we\n> >> can then create an instance of CameraLens to represent it.\n> >>\n> >> Signed-off-by: Daniel Scally <djrscally@gmail.com>\n> >\n> > Given that Han-lin's patch that add model-based matching hasn't been\n> > merged yet, I think this should be rebased on top of the master branch\n> > directly. There's no need to merge model-based matching to replace it\n> > immediately after.\n> \n> Did the patch introducing the CameraLens class get merged, then? I can\n> rebase onto master in that case, no problem.\n\nNot yet. Feel free to include it in your series to develop its\nintegration.\n\n> >> ---\n> >>\n> >> Alternatively rather than replace the matching on model names we could try\n> >> the ancillary links first and then simply guard the existing model matching\n> >> with an if (!lens_) ...\n> >\n> > I think ancillary links are good enough, there's no need for model-based\n> > matching.\n> \n> Righto.\n> \n> >>  src/libcamera/pipeline/ipu3/cio2.cpp | 45 +++++++++++++++-------------\n> >>  1 file changed, 25 insertions(+), 20 deletions(-)\n> >>\n> >> diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> >> index 59b2f586..169e7b54 100644\n> >> --- a/src/libcamera/pipeline/ipu3/cio2.cpp\n> >> +++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n> >> @@ -161,30 +161,35 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n> >>  \t}\n> >>  \n> >>  \t/*\n> >> -\t * \\todo Read the lens model from the sensor itself or from a device\n> >> -\t * database. For now use default values taken from ChromeOS database.\n> >> +\t * Sensors sometimes have ancillary devices such as a Lens or Flash\n> >> +\t * that could be linked to the MediaEntity - search for and handle\n> >> +\t * any such device (for now, we can only handle MEDIA_ENT_F_LENS)\n> >> +\t *\n> >> +\t * \\todo Handle MEDIA_ENT_F_FLASH too.\n> >>  \t */\n> >> -\tstatic std::unordered_map<std::string, std::string> sensorLens = {\n> >> -\t\t{ \"ov13858\", \"dw9714\" },\n> >> -\t\t{ \"imx258\", \"dw9807\" },\n> >> -\t\t{ \"imx355\", \"ak7375\" }\n> >> -\t};\n> >> -\n> >> -\tauto it = sensorLens.find(sensor_->model());\n> >> -\tif (it != sensorLens.end()) {\n> >> -\t\tconst std::vector<MediaEntity *> &entities = media->entities();\n> >> -\t\tfor (auto ent : entities) {\n> >> -\t\t\tif (ent->function() == MEDIA_ENT_F_LENS) {\n> >> -\t\t\t\tlens_ = std::make_unique<CameraLens>(ent);\n> >> +\tconst std::vector<MediaLink *> &ancillary_links = sensorEntity->ancillary_links();\n> >> +\tif (!ancillary_links.empty()) {\n> >> +\t\tfor (auto it : ancillary_links) {\n> >> +\t\t\tMediaEntity *ancillaryEntity = it->ancillary();\n> >> +\n> >> +\t\t\tswitch (ancillaryEntity->function()) {\n> >> +\t\t\tcase MEDIA_ENT_F_LENS:\n> >> +\t\t\t\tlens_ = std::make_unique<CameraLens>(ancillaryEntity);\n> >>  \t\t\t\tret = lens_->init();\n> >> -\t\t\t\tif (!ret && lens_->model() == it->second) {\n> >> -\t\t\t\t\tbreak;\n> >> +\t\t\t\tif (ret) {\n> >> +\t\t\t\t\tLOG(IPU3, Error)\n> >> +\t\t\t\t\t\t<< \"Error during CameraLens init\";\n> >> +\t\t\t\t\treturn ret;\n> >>  \t\t\t\t}\n> >> -\t\t\t\tlens_.reset();\n> >> +\t\t\t\tbreak;\n> >> +\t\t\tcase MEDIA_ENT_F_FLASH:\n> >> +\t\t\t\tLOG(IPU3, Warning)\n> >> +\t\t\t\t\t<< \"Flash not yet supported\";\n> >> +\t\t\t\tbreak;\n> >> +\t\t\tdefault:\n> >> +\t\t\t\tLOG(IPU3, Warning)\n> >> +\t\t\t\t\t<< \"Unsupported entity function\";\n> >>  \t\t\t}\n> >\n> > Could we simplify the pipeline handlers a bit by moving at least the\n> > lookup of the VCM entity to the CameraSensor class ?\n> \n> Sure; I actually moved it to ::init() now, that sound ok?\n\nDo you mean CameraSensor::init() ? Yes, that sounds fine (although you\nmay want to move it to a private function called by init(), there's lots\nbeing done at init time already).\n\n> >> -\t\t\tif (!lens_)\n> >> -\t\t\t\tLOG(IPU3, Warning) << \"Lens device \"\n> >> -\t\t\t\t\t\t   << it->second << \" not found\";\n> >>  \t\t}\n> >>  \t}\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 027C0BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Nov 2021 00:11:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D58456058C;\n\tMon, 29 Nov 2021 01:11:53 +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 DE5526011D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Nov 2021 01:11:51 +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 4B20693;\n\tMon, 29 Nov 2021 01:11:51 +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=\"twvv3Kfl\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638144711;\n\tbh=nk8nu2UrGyheFSQWMjnKDVCeKTTLDKeXyWR96kpc80k=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=twvv3Kfl8FA41PG76RXHunkA19ucXRuSjiuFlTDWs5ynUjZJrw/oi1WqXBnXYSCXZ\n\t3DWvttbTyeoLlsyYBtxkv5TM+SEji5Pa6Lfly1pPvxSRj/NCoPpNFQaj3dCYb3qJnY\n\tx/AIvrokZpfl5Vag3xrquX68WYWO04c7fIG3eCBg=","Date":"Mon, 29 Nov 2021 02:11:26 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Daniel Scally <djrscally@gmail.com>","Message-ID":"<YaQarm8cI70giybk@pendragon.ideasonboard.com>","References":"<20211126003118.42356-1-djrscally@gmail.com>\n\t<20211126003118.42356-4-djrscally@gmail.com>\n\t<YaQArIldXWAfG/QM@pendragon.ideasonboard.com>\n\t<2e1fd1fc-96b0-df1c-6188-875e348c749a@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<2e1fd1fc-96b0-df1c-6188-875e348c749a@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH 3/5] libcamera: ipu3-cio2: Discover\n\tVCMs 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>"}}]