From patchwork Sun Jan 31 22:47:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 11099 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com 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 8756EBD808 for ; Sun, 31 Jan 2021 22:47:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 53FCD6840E; Sun, 31 Jan 2021 23:47:48 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="hcoGpm93"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9E342683FF for ; Sun, 31 Jan 2021 23:47:37 +0100 (CET) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D12531850; Sun, 31 Jan 2021 23:47:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1612133256; bh=veZtHrkAHVBklEY0+Sz5xGy72xisPX77x1nnWAKUZQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hcoGpm93r3xZdktSxVEguXJPxzX6zVa4Y0szpFtEEJiHJaxqj8CZqSL4amDWcsBez r/kQkophXYXonp0NzfsgO3lOCt7aRjViaw08RrD0obcHamnq8qEukvv9anc/z0/YE6 pdj0VKE5GmzYKCeqMYpgMf4o1nwfZajCDCBQFFsI= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 1 Feb 2021 00:47:02 +0200 Message-Id: <20210131224702.8838-21-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210131224702.8838-1-laurent.pinchart@ideasonboard.com> References: <20210131224702.8838-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 20/20] libcamera: pipeline: simple: Enable multiple streams for compatible devices 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: , Cc: Phi-Bang Nguyen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Allow support for multiple streams on a per-device basis. The decision should be made based on the ability of the converter to run multiple times within the duration of one frame. Hardcode it in SimplePipelineInfo for now. We may later compute the number of supported streams dynamically based on the requested configuration, using converter bandwidth information instead of a hardcoded fixed value. All platforms are currently limited to a single stream until they get successfully tested with multiple streams. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/simple/simple.cpp | 39 +++++++++++++----------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 55a5528611c8..4a8a7ed24960 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -126,14 +126,15 @@ class SimplePipelineHandler; struct SimplePipelineInfo { const char *driver; const char *converter; + unsigned int numStreams; }; namespace { static const SimplePipelineInfo supportedDevices[] = { - { "imx7-csi", "pxp" }, - { "qcom-camss", nullptr }, - { "sun6i-csi", nullptr }, + { "imx7-csi", "pxp", 1 }, + { "qcom-camss", nullptr, 1 }, + { "sun6i-csi", nullptr, 1 }, }; } /* namespace */ @@ -141,7 +142,9 @@ static const SimplePipelineInfo supportedDevices[] = { class SimpleCameraData : public CameraData { public: - SimpleCameraData(SimplePipelineHandler *pipe, MediaEntity *sensor); + SimpleCameraData(SimplePipelineHandler *pipe, + const SimplePipelineInfo *info, + MediaEntity *sensor); bool isValid() const { return sensor_ != nullptr; } @@ -254,13 +257,12 @@ private: */ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, + const SimplePipelineInfo *info, MediaEntity *sensor) - : CameraData(pipe) + : CameraData(pipe), streams_(info->numStreams) { int ret; - streams_.resize(1); - /* * Walk the pipeline towards the video node and store all entities * along the way. @@ -864,25 +866,26 @@ int SimplePipelineHandler::queueRequestDevice(Camera *camera, Request *request) bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) { + const SimplePipelineInfo *info = nullptr; MediaDevice *converter = nullptr; - for (const SimplePipelineInfo &info : supportedDevices) { - DeviceMatch dm(info.driver); + for (const SimplePipelineInfo &inf : supportedDevices) { + DeviceMatch dm(inf.driver); media_ = acquireMediaDevice(enumerator, dm); - if (!media_) - continue; - - if (!info.converter) + if (media_) { + info = &inf; break; - - DeviceMatch converterMatch(info.converter); - converter = acquireMediaDevice(enumerator, converterMatch); - break; + } } if (!media_) return false; + if (info->converter) { + DeviceMatch converterMatch(info->converter); + converter = acquireMediaDevice(enumerator, converterMatch); + } + /* Locate the sensors. */ std::vector sensors; @@ -926,7 +929,7 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) for (MediaEntity *sensor : sensors) { std::unique_ptr data = - std::make_unique(this, sensor); + std::make_unique(this, info, sensor); if (!data->isValid()) { LOG(SimplePipeline, Error) << "No valid pipeline for sensor '"