{"id":15033,"url":"https://patchwork.libcamera.org/api/patches/15033/?format=json","web_url":"https://patchwork.libcamera.org/patch/15033/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211203224230.38700-4-djrscally@gmail.com>","date":"2021-12-03T22:42:26","name":"[libcamera-devel,v2,3/7] libcamera: camera_sensor: Discover VCMs through ancillary links","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"1b2fced612add649f2f1a499b876b1ac72a3e885","submitter":{"id":90,"url":"https://patchwork.libcamera.org/api/people/90/?format=json","name":"Daniel Scally","email":"djrscally@gmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15033/mbox/","series":[{"id":2815,"url":"https://patchwork.libcamera.org/api/series/2815/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2815","date":"2021-12-03T22:42:23","name":"Enumerate CameraLens by following sensor's ancillary links","version":2,"mbox":"https://patchwork.libcamera.org/series/2815/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15033/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15033/checks/","tags":{},"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 902CABF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  3 Dec 2021 22:42:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5AF0760868;\n\tFri,  3 Dec 2021 23:42:42 +0100 (CET)","from mail-wr1-x433.google.com (mail-wr1-x433.google.com\n\t[IPv6:2a00:1450:4864:20::433])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1FD4460832\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 Dec 2021 23:42:39 +0100 (CET)","by mail-wr1-x433.google.com with SMTP id c4so8639695wrd.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 03 Dec 2021 14:42:39 -0800 (PST)","from localhost.localdomain\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\to25sm3939919wms.17.2021.12.03.14.42.38\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 03 Dec 2021 14:42:38 -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=\"hs147ox7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=b67B6PydBk9/XDflw+3N/GXguKDJd77sJVZ13CnMHl0=;\n\tb=hs147ox7cTI8S9DJKLAWxPUDqrAZ60rlp8gM4Ny1Hw9IxSSvgbxMxD/uB20qbGiJlV\n\t0ByW5B8VVe102EtGsAst1OtB8/e+kuXG2ezTyDsVtCCKUurrljW3/YVmJMxnIPMdzHu9\n\tCPJC8+Ig0RpaxCGyOf5IzODlrXxuLYNqdESG3LIOLp0VcWaiK2ZjqQUaMyVrWAetB8j8\n\tmm0SB0db6nLMLNanipOcHzKgIOgpNFgx2qkwE5tnOVw9xpMko5YZW3/k0oVHoLFz/MxN\n\tnxwXlA0q2ElWcwox9Tc0+Ct+pLy73ujOX3J8zavW7Y4SbTuyPFp494GtHzbrj6ZMC3XL\n\t18QA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=b67B6PydBk9/XDflw+3N/GXguKDJd77sJVZ13CnMHl0=;\n\tb=iDu6EtB5K594l1Fk5QY3FP2AKxXwpmj5jdueUL/cgNrXZjHHWCYXfhyUMPCH0BOmpI\n\tPRjem2yQakluiG8xbTBEs0gkzirZt1yVUbXEuvj5Fkte2iqrbWyvYLNNXTwFbKcYVFkq\n\tPcT20TlQbus9KG1m7P4fCMzNfggpIjdU0gGkJTAc5QYo9ML9aJWGBSG2wlvB/apn5+yM\n\tDHqgmm0a4PCBsb+j47edygVB1kqnYaGOfFfS3KnB+37OvcYQ+1sYfynRA1doRW8R4eB5\n\t0sKXf2hBbUK+AzjEhAHMHX89eX64TnYQfessyEKQj6kf9axEqDc17SaoYhFLTDXOpE8d\n\ttFcA==","X-Gm-Message-State":"AOAM533V5TksIuPYtuGOPbYiOfng0FRdIFy7Dqzt1eHylNWTG3B7sGi/\n\tzqJkakpBOMq4BwrAgs/P/ctgL4twjGk=","X-Google-Smtp-Source":"ABdhPJwmI/CfF5hPEW9xOZmf7yRIZItsw3/1dxOEX1Dk4UpVDbCtcvRXmnVfnOyzSb3s+nMee50VJA==","X-Received":"by 2002:adf:fd90:: with SMTP id\n\td16mr24124093wrr.385.1638571358903; \n\tFri, 03 Dec 2021 14:42:38 -0800 (PST)","From":"Daniel Scally <djrscally@gmail.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  3 Dec 2021 22:42:26 +0000","Message-Id":"<20211203224230.38700-4-djrscally@gmail.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20211203224230.38700-1-djrscally@gmail.com>","References":"<20211203224230.38700-1-djrscally@gmail.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 3/7] libcamera: camera_sensor: 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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add a function to check for and initialise any VCMs linked to the\nCameraSensor's entity by ancillary links. This should initialise\nthe lens_ member with the linked entity. Call the new function\nduring CameraSensor::init().\n\nSigned-off-by: Daniel Scally <djrscally@gmail.com>\n---\nChanges 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(+)","diff":"diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\nindex 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_;\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 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+\t\t\t\treturn ret;\n+\t\t\t}\n+\t\t\tbreak;\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+\t\tdefault:\n+\t\t\tLOG(CameraSensor, Warning)\n+\t\t\t\t<< \"Unsupported ancillary entity function\";\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n /**\n  * \\fn CameraSensor::model()\n  * \\brief Retrieve the sensor model name\n","prefixes":["libcamera-devel","v2","3/7"]}