From patchwork Thu Aug 5 22:24:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13235 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 4F5BDC3239 for ; Thu, 5 Aug 2021 22:25:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1B0CB6888E; Fri, 6 Aug 2021 00:25:00 +0200 (CEST) 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="V/G+tvud"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 244AC6880D for ; Fri, 6 Aug 2021 00:24:57 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AEFCBE1A for ; Fri, 6 Aug 2021 00:24:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628202296; bh=EI8EOkLoNvotyI11OoGreFBjJlAWkJbuG/qu6UTgkS0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=V/G+tvud1zrNZWX7+63z+pPa3dqWx916hz/BYZqREQmIjBXjxi6pDcfnkjqSSHRDJ kfZ3pPt6fEpm85keAmTfQCDTH5rERc085mXAE4muzFk4/dZXFWM5rII4cBbQfPNlxI iH1s0e7TI4Hzg6r7NSQDjvI1Rm0IZpd5Cn59mvuY= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 6 Aug 2021 01:24:30 +0300 Message-Id: <20210805222436.6263-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210805222436.6263-1-laurent.pinchart@ideasonboard.com> References: <20210805222436.6263-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 04/10] libcamera: pipeline: simple: Store video node entity in camera data 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" Store the entity corresponding to the video node at the end of the pipeline in the SimpleCameraData::entities_ list. This requires special handling of the video node in the loops that iterate over all entities, but will be useful to implement mutually exclusive access to entities for concurrent camera usage. Signed-off-by: Laurent Pinchart --- src/libcamera/pipeline/simple/simple.cpp | 29 ++++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 744f842dbfe6..99ecd640349c 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -194,8 +194,13 @@ public: }; std::vector streams_; - std::unique_ptr sensor_; + + /* + * All entities in the pipeline, from the camera sensor to the video + * node. + */ std::list entities_; + std::unique_ptr sensor_; V4L2VideoDevice *video_; std::vector configs_; @@ -309,12 +314,11 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, std::unordered_map parents; MediaEntity *entity = nullptr; MediaEntity *video = nullptr; + MediaPad *sinkPad; queue.push({ sensor, nullptr }); while (!queue.empty()) { - MediaPad *sinkPad; - std::tie(entity, sinkPad) = queue.front(); queue.pop(); @@ -347,8 +351,11 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, /* * With the parents, we can follow back our way from the capture device - * to the sensor. + * to the sensor. Store all the entities in the pipeline, from the + * camera sensor to the video node, in entities_. */ + entities_.push_front({ entity, sinkPad, nullptr, nullptr }); + for (auto it = parents.find(entity); it != parents.end(); it = parents.find(entity)) { const Entity &e = it->second; @@ -484,6 +491,9 @@ int SimpleCameraData::setupLinks() * want to enable) before enabling the pipeline link. */ for (SimpleCameraData::Entity &e : entities_) { + if (!e.link) + break; + MediaEntity *remote = e.link->sink()->entity(); for (MediaPad *pad : remote->pads()) { for (MediaLink *link : pad->links()) { @@ -524,6 +534,9 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format, return ret; for (const Entity &e : entities_) { + if (!e.link) + break; + MediaLink *link = e.link; MediaPad *source = link->source(); MediaPad *sink = link->sink(); @@ -1050,8 +1063,14 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) if (entities.empty()) return false; - /* Create and open V4L2Subdev instances for all the entities. */ + /* + * Create and open V4L2Subdevice instances for all entities + * corresponding to a V4L2 subdevice. + */ for (MediaEntity *entity : entities) { + if (entity->type() != MediaEntity::Type::V4L2Subdevice) + continue; + auto elem = subdevs_.emplace(std::piecewise_construct, std::forward_as_tuple(entity), std::forward_as_tuple(entity));