From patchwork Thu May 6 18:06:06 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: 12216 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 560E6BDE7F for ; Thu, 6 May 2021 18:06:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CFEF668918; Thu, 6 May 2021 20:06:24 +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="EU/4m4x4"; dkim-atps=neutral Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8228B68901 for ; Thu, 6 May 2021 20:06:23 +0200 (CEST) Received: by mail-wr1-x433.google.com with SMTP id t18so6575746wry.1 for ; Thu, 06 May 2021 11:06:23 -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=GsDPhECXsTuFqXG5XhYx3x5CJyiD480eYXrWI7N1qF4=; b=EU/4m4x48YdstLfAOn74FTxxdz3hu9qaolVimpL4tzR0zKJNxC/C20H1gVoj90dDJt gr+Za6Qfvq2O5EyCAZ+Xj+S5myXpzfsbmnjZhH349Wdb2aKofMSsfiqAnsIchDl5Pgkq mVZ7c+hRY1KixhRXtEgAcFIxEfB4fUpHAcZE0nU7xW1tPwrZGNIeIRqEaIYspBdEU225 lKF+hg/5CgdCSlmJj43XDTzeDh8IvVhQRwMgzBMpZ/P10ym3yS0FZHM+wUwlhbHMfBol SsTNIeJPEp0BT8iOcEzAqgxY5q9Iy45hYH0tOb9h/ivMQtA1N6FYCGSNOcN+2G8etZp0 at+Q== 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=GsDPhECXsTuFqXG5XhYx3x5CJyiD480eYXrWI7N1qF4=; b=lSeMNMW1Tsr/qc3v204OhFs7YgOUBM/FvV0QEbTXnUqXaqX8fOdzi/4CPkUOGfHJsY DpwkUVx1TdMneovh/c+Uv9Wx5zZxIf6zoaOIlTinzRAkz3OI6CYa3aE2MV6zl/QuolpR +KS62939cpvWqPkwerAjXAux4/hehjPp0JHsJ0GGfLfDr1f1AK2YInbALvyjbk7eO/y0 huOITMZTO3H4+1E/pqUDhtCpTGtPy/Ldhg/3RaxNWKQo0YCAc8UQKzQFNpTGGmFNwQ7m OTCMKFjaIju1cLpkTo9spQKcsErbLjrdkg4JZRCeqddfOnC/ckm/BdTwc8DSp6Dz8RSw ttAA== X-Gm-Message-State: AOAM530IKwBAC+yZYr6lXRwzPobNRHzK4URU9FbcfnR+HBurpSWcr2yB oRRwtYbWWt0g00udc0lhmCNOx4OhJLq5LA== X-Google-Smtp-Source: ABdhPJwsH0ppTGqI2TkLSvol9BVdwZNGZNPKWihBDOagj+A6SIVt5zptXwqzxs2Qum6BSG7eIN2ypg== X-Received: by 2002:a5d:6e11:: with SMTP id h17mr6803284wrz.331.1620324382888; Thu, 06 May 2021 11:06:22 -0700 (PDT) Received: from localhost.localdomain (206.159.69.91.rev.sfr.net. [91.69.159.206]) by smtp.googlemail.com with ESMTPSA id v15sm10714297wmj.39.2021.05.06.11.06.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 11:06:21 -0700 (PDT) From: Phi-Bang Nguyen To: libcamera-devel@lists.libcamera.org Date: Thu, 6 May 2021 20:06:06 +0200 Message-Id: <20210506180606.43447-1-pnguyen@baylibre.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] 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" The supportedDevices may contain entries which have the same driver but different converters. For example, if we add these two entries: { "mtk-seninf", "mtk-mdp", 3 }, { "mtk-seninf", "mtk-mdp3", 3 }, the simple pipeline handler will always take the first one where it can acquire the driver and skip the rest. So, make the changes to support this usecase. Signed-off-by: Phi-Bang Nguyen Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/simple/simple.cpp | 30 +++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index f6095d38..4c87ec4c 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", {} }, + { "sun6i-csi", {} }, }; } /* 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,13 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) if (!media_) return false; - if (info->converter) { - DeviceMatch converterMatch(info->converter); + for (const auto &[name, streams] : info->converters) { + DeviceMatch converterMatch(name); converter = acquireMediaDevice(enumerator, converterMatch); + if (converter) { + numStreams = streams; + break; + } } /* Locate the sensors. */ @@ -983,7 +991,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 '"