From patchwork Thu Aug 5 22:24:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13234 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 80741C3235 for ; Thu, 5 Aug 2021 22:25:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AFBF96888B; Fri, 6 Aug 2021 00:24:59 +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="ZgukgEu4"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B893D68811 for ; Fri, 6 Aug 2021 00:24:56 +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 60D874FB 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=cED4Slz0594G/5GZEExCd3pstt5tHhUSAFRaF8FPMmg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZgukgEu4AzIc55q1dQTVBKsUt1psEHmWDpsG9yiae2K4VcD+kglarLfzu06STXAQk n13JWPFe5DbCjOfJ3FEgj5lD+zF1MXTLTPatIg26Vu+1ys9fPhQr0n/CKPeNpH0SKB AwIWswb1XsWuf0x0joOJRJGsDrSOul3ZFdikgRY8= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 6 Aug 2021 01:24:29 +0300 Message-Id: <20210805222436.6263-4-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 03/10] libcamera: pipeline: simple: Delay opening of video device until init() 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 video device is currently opened in the SimpleCameraData constructor. This requires opening the video devices on-demand the first time they're accessed, which gets in the way of refactoring of per-entity data storage in the pipeline handler. Move opening of the video device to the SimpleCameraData::init() function. The on-demand open mechanism isn't touched yet, it will be refactored later. Signed-off-by: Laurent Pinchart --- src/libcamera/pipeline/simple/simple.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index e0695d052629..744f842dbfe6 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -308,6 +308,7 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, /* Remember at each entity where we came from. */ std::unordered_map parents; MediaEntity *entity = nullptr; + MediaEntity *video = nullptr; queue.push({ sensor, nullptr }); @@ -321,7 +322,7 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, if (entity->function() == MEDIA_ENT_F_IO_V4L) { LOG(SimplePipeline, Debug) << "Found capture device " << entity->name(); - video_ = pipe->video(entity); + video = entity; break; } @@ -341,7 +342,7 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, } } - if (!video_) + if (!video) return; /* @@ -384,6 +385,12 @@ int SimpleCameraData::init() SimpleConverter *converter = pipe->converter(); int ret; + video_ = pipe->video(entities_.back().entity); + if (!video_) { + LOG(SimplePipeline, Error) << "Failed to open video device"; + return -ENODEV; + } + /* * Setup links first as some subdev drivers take active links into * account to propagate TRY formats. Such is life :-(