From patchwork Fri Nov 26 00:31:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 14786 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 34DDABDB13 for ; Fri, 26 Nov 2021 00:31:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DCF0D604FB; Fri, 26 Nov 2021 01:31:35 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DLaFPl9/"; dkim-atps=neutral Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 30EE760499 for ; Fri, 26 Nov 2021 01:31:30 +0100 (CET) Received: by mail-wr1-x435.google.com with SMTP id i5so14976528wrb.2 for ; Thu, 25 Nov 2021 16:31:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WiOK10IpVso/amOg/JULzN+ZlDMbZCiXCePGnabe+Y8=; b=DLaFPl9/zVgKMzN/9UmawBuMXIgK/LxxgrMU1Fp1WRAqCmZNOI8C/5flCw3ohnm+jx kf2oylfWGtbmei0pTBgwpl90Fa7F0yLvk5aBDZv3L4YOiyn0v+vDgUiKJramhwtMwjOs ip0LvSb75EX9WtVs9mH1Sz4AgTuQiKdevj1QXZjvUIELv4TbcFSXZ2m7Yf9hXDnRpDKk /tGH+TnFssFC2Suu6oI0SYPYbWP5axq8ldzfK4FEhUSFNXGfMWc4Mnnb35ew1468uioq jxi2WeV6TaFRWvkROHD48QtpkW1SuOIJwGTwGKcyQfPx5oBaYSEeqgcqvXopBMODH4sA RrOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WiOK10IpVso/amOg/JULzN+ZlDMbZCiXCePGnabe+Y8=; b=r45aut4QRVC23hfJG2Nadl3SAfQG2F8fIiUDdN+Lj+lDnknhNjAeZEAFD1ig6Y8s/N q0tZAxtQSEtPlfv0AC8JatoonXaxtCmVl7MCg3hfLBAjKUf3wYrrcZEG7tZABGyBoRmo LxfPNVkVoMJRKtQw486Jq220KrDfYp3VN+EF9aKLO1Lkd/Kp2hQvPBCeiVlCLOF+z9F9 uZM2hTyUkgMA86H6tr1B2gqhGF0orbZ1oE7dSF5CXSEI1EOn4BdeAI6gd7Xwj3wvPlad bBg5A5p8NqhK0vYkcTCR93jFl6D8C/v+eoObF+mRB2ORh0P6Cigk48EFgJzU8RwgmYyD vuCA== X-Gm-Message-State: AOAM533KHmAlfuCiwgjNLyqvb6Tj+D94IBZGG5zX1K7gzJXv9hnYKT+b KX6ABi3uFX7KgkRf/UEoIeTQFZQwkw4= X-Google-Smtp-Source: ABdhPJxiBIq9TMyRoaTqLNPPUOGGqq/RvyOG3bjYxYEeTxx4/6qP5QV0zOi0MOc5yfvNQSrkaHnt1A== X-Received: by 2002:adf:d1c2:: with SMTP id b2mr11031705wrd.114.1637886689713; Thu, 25 Nov 2021 16:31:29 -0800 (PST) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id b188sm4381455wmd.45.2021.11.25.16.31.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 16:31:29 -0800 (PST) From: Daniel Scally To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Nov 2021 00:31:16 +0000 Message-Id: <20211126003118.42356-4-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211126003118.42356-1-djrscally@gmail.com> References: <20211126003118.42356-1-djrscally@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] libcamera: ipu3-cio2: Discover VCMs through ancillary links X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Rather than attempting to discover VCMs via model name matching we should follow the ancillary links that define the relationship between the two devices to locate any entities linked to the sensor. Where we have linked entities with the function MEDIA_ENT_F_LENS we can then create an instance of CameraLens to represent it. Signed-off-by: Daniel Scally --- Alternatively rather than replace the matching on model names we could try the ancillary links first and then simply guard the existing model matching with an if (!lens_) ... src/libcamera/pipeline/ipu3/cio2.cpp | 45 +++++++++++++++------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp index 59b2f586..169e7b54 100644 --- a/src/libcamera/pipeline/ipu3/cio2.cpp +++ b/src/libcamera/pipeline/ipu3/cio2.cpp @@ -161,30 +161,35 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index) } /* - * \todo Read the lens model from the sensor itself or from a device - * database. For now use default values taken from ChromeOS database. + * Sensors sometimes have ancillary devices such as a Lens or Flash + * that could be linked to the MediaEntity - search for and handle + * any such device (for now, we can only handle MEDIA_ENT_F_LENS) + * + * \todo Handle MEDIA_ENT_F_FLASH too. */ - static std::unordered_map sensorLens = { - { "ov13858", "dw9714" }, - { "imx258", "dw9807" }, - { "imx355", "ak7375" } - }; - - auto it = sensorLens.find(sensor_->model()); - if (it != sensorLens.end()) { - const std::vector &entities = media->entities(); - for (auto ent : entities) { - if (ent->function() == MEDIA_ENT_F_LENS) { - lens_ = std::make_unique(ent); + const std::vector &ancillary_links = sensorEntity->ancillary_links(); + if (!ancillary_links.empty()) { + for (auto it : ancillary_links) { + MediaEntity *ancillaryEntity = it->ancillary(); + + switch (ancillaryEntity->function()) { + case MEDIA_ENT_F_LENS: + lens_ = std::make_unique(ancillaryEntity); ret = lens_->init(); - if (!ret && lens_->model() == it->second) { - break; + if (ret) { + LOG(IPU3, Error) + << "Error during CameraLens init"; + return ret; } - lens_.reset(); + break; + case MEDIA_ENT_F_FLASH: + LOG(IPU3, Warning) + << "Flash not yet supported"; + break; + default: + LOG(IPU3, Warning) + << "Unsupported entity function"; } - if (!lens_) - LOG(IPU3, Warning) << "Lens device " - << it->second << " not found"; } }