From patchwork Mon May 3 12:25:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phi-bang Nguyen X-Patchwork-Id: 12187 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 5E247BDE78 for ; Mon, 3 May 2021 12:25:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1C9B360511; Mon, 3 May 2021 14:25:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="rMVVhSSK"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4439C60511 for ; Mon, 3 May 2021 14:25:41 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id n205so2318957wmf.1 for ; Mon, 03 May 2021 05:25:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LRal6OKz6/fLzgNS6RylPR6MI9yFWTnEq4J1yw09wwA=; b=rMVVhSSK0X71u8ctSCOywpj8kNng771R15U812uNRSjJHR/4u5x3hqNr1iMgoHez2I OHSQ7YqYextjE6C34c+102mL3L8onE60s6iv9b3TUX0chFI1UW756aGXio3WckmJCBvm 4UsLIKPrg0EfflXYdP1AGA4BfA7XDPvg6e8uB/hSsPZxBD8ZOVfyxElfJTor1k8qR7bU SazeiYuJ/RXwtOaN4nnM69fTFRGd9tTLboc2kyktDK/GZTYyXXvsrUtE2oSuF8PzV/TD ufc7yTg0NCqkQS23WBmmOBbFjnKnrIjUQsLieBXBz1WQk4i+gdF4GvDXrTtv+qtMAx+A V/Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LRal6OKz6/fLzgNS6RylPR6MI9yFWTnEq4J1yw09wwA=; b=FQsDyEu4bt2d5PcpZcDY4F92gtA+wWIDq9yC+A8PlZKyfLmnhWP8qIbHVeDr5r31jm sysnrR2Cur3F06ICpuZ+ExfT5hoc/o5L95xANABMawoNrN32AZwFVs5PKLJyHPd/jXu+ StXTI+O6wjoM6W1Hu1Mj9DWhaLWH0a3GtAnFhUA4rLPUv8mlQODTOm5+FvcisH6YKJJE iu0OhZsm1Toe8sJkf/KQZeprqgfS7BjX3KbEJQ8H07BuZV+Nw9XMBCWTy4VVhVoce/gQ +Fd+kEuSvuMhbwSibz9a3J1Qt47SV/OYZuBCHIVbgR6V/0PaQVdPWWesdztWXxK98lJL Rsdw== X-Gm-Message-State: AOAM5327H2Ajkv/0wKqcGxF1QzSNSMZ/LKZmmwtmbiwSGaioTI4q7iIb rZYtWErXf7OxMbSRpI/RhwKo8UIUzdNTTA== X-Google-Smtp-Source: ABdhPJwIey+vYEGgFCE2ZXRFL/82b0fOf4PKWa78QpSB2i+AX7mEe7Hfl8Uxglokzwt2g+3JHtGPNA== X-Received: by 2002:a1c:4c09:: with SMTP id z9mr21212943wmf.104.1620044740707; Mon, 03 May 2021 05:25:40 -0700 (PDT) Received: from localhost.localdomain (206.159.69.91.rev.sfr.net. [91.69.159.206]) by smtp.googlemail.com with ESMTPSA id t206sm11373299wmb.11.2021.05.03.05.25.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 05:25:40 -0700 (PDT) From: Phi-Bang Nguyen To: libcamera-devel@lists.libcamera.org Date: Mon, 3 May 2021 14:25:17 +0200 Message-Id: <20210503122518.745088-1-pnguyen@baylibre.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] pipeline: simple: Rework the supportedDevices list 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" There is a usecase that the same driver may go with a converter on a platform and with another converter on another platform. Currently, the simple pipeline handler only takes the 1st driver it can acquire in the supported devices list and skip the rest. This makes it take the wrong converter for the above usecase. So, make the changes to support the above usecase. Signed-off-by: Phi-Bang Nguyen --- src/libcamera/pipeline/simple/simple.cpp | 34 +++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index f6095d38..9a572694 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -127,16 +127,19 @@ class SimplePipelineHandler; struct SimplePipelineInfo { const char *driver; - const char *converter; - unsigned int numStreams; + /* + * Each converter in the list contains the name + * and the number of streams it supports. + */ + std::vector> converters; }; namespace { static const SimplePipelineInfo supportedDevices[] = { - { "imx7-csi", "pxp", 1 }, - { "qcom-camss", nullptr, 1 }, - { "sun6i-csi", nullptr, 1 }, + { "imx7-csi", { { "pxp", 1 } } }, + { "qcom-camss", { { nullptr, 1 } } }, + { "sun6i-csi", { { nullptr, 1 } } }, }; } /* namespace */ @@ -145,7 +148,7 @@ class SimpleCameraData : public CameraData { public: SimpleCameraData(SimplePipelineHandler *pipe, - const SimplePipelineInfo *info, + unsigned int numStreams, MediaEntity *sensor); bool isValid() const { return sensor_ != nullptr; } @@ -266,9 +269,9 @@ private: */ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, - const SimplePipelineInfo *info, + unsigned int numStreams, MediaEntity *sensor) - : CameraData(pipe), streams_(info->numStreams) + : CameraData(pipe), streams_(numStreams) { int ret; @@ -934,6 +937,7 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) { const SimplePipelineInfo *info = nullptr; MediaDevice *converter = nullptr; + unsigned int numStreams = 1; for (const SimplePipelineInfo &inf : supportedDevices) { DeviceMatch dm(inf.driver); @@ -947,9 +951,15 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) if (!media_) return false; - if (info->converter) { - DeviceMatch converterMatch(info->converter); - converter = acquireMediaDevice(enumerator, converterMatch); + for (const auto &cvt : info->converters) { + if (cvt.first) { + DeviceMatch converterMatch(cvt.first); + converter = acquireMediaDevice(enumerator, converterMatch); + if (converter) { + numStreams = cvt.second; + break; + } + } } /* Locate the sensors. */ @@ -983,7 +993,7 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) for (MediaEntity *sensor : sensors) { std::unique_ptr data = - std::make_unique(this, info, sensor); + std::make_unique(this, numStreams, sensor); if (!data->isValid()) { LOG(SimplePipeline, Error) << "No valid pipeline for sensor '"