From patchwork Thu Jan 5 04:37:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 18091 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 A1221C3291 for ; Thu, 5 Jan 2023 04:38:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 20612625EF; Thu, 5 Jan 2023 05:38:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1672893484; bh=MiBEvbXlz+1BGq21sH77k9hUxEq8grZsBfiZJbRKcxU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=FznFSNpl+QAoUc2UHr9lv9vUoB2RZ3tT2mbPjqOQw/uwNDyz7sVTC31SOVOA6Q4Wt l6gjRYbVrmmngWeTWlSljNchTPHdM8A4Av+sKakqAqszeqQAD4Zr76Obiz2mGlKDB7 um6CqAVoFpG0751sp5GnJJpAskZuJv2DSlHZBJ9q3zeiTSZoKvQxwbxgPWbxQ/WwhP ah7fKsfb9p2KHNYiXV1NUxSsdpkhK70kx2xHCENm1j3b/J1oBzx7DlNxmeH74p3c6p mg9N/b4ANytTCcLi0D7AzSeQsmgE1zY8vKfQSzdfTj2NbYW46eNx2vDBPd5BJ3yveG Fde86hKgRDB9w== Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C2FCE625EB for ; Thu, 5 Jan 2023 05:38:00 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="mgnmjeTc"; dkim-atps=neutral Received: by mail-pj1-x102d.google.com with SMTP id v23so38656979pju.3 for ; Wed, 04 Jan 2023 20:38:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E+5l/E5dTt8O4fLT9DI1XkChOsHxPPry4q2+/5TrVVc=; b=mgnmjeTcBGuzyQIdRZ8iFTVtqhALDHFNBNlrK1hBmXuCiVlLFjt4986uaRWtil0wXH At1K3ps7t17OX1oBe9hahZ1CXkPudC0vbYfdQox3tCBwY1+LqdezQrspn9A5x82b+mJL LQKdPnRRYIH7Xz1V6FFRC7G6cIaxKYJaUaWps= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E+5l/E5dTt8O4fLT9DI1XkChOsHxPPry4q2+/5TrVVc=; b=hGFG0FKlraeqU/9K2LsaY4uHdMo/CSZV/ktZ8Bl7O3dWXMNnP1hTb0rSOw9tZf6XQE +MzwxrolTqShQ+GXvm1p4B/WlfzPn9JqPZuSPdH5aLVUjVBSv5GeS2/VFDEW9JWaCSTg lbaWQ2qwJkp7gcvkFCEBdhYzNV6eEafY00vD/c6OB+jo6FIIDn/OZ++ewfScpHRNqKd5 dhOMV9gzeffu3jivsjdRDB95HoI4JwCTzdi4t1H5RD9Ke23s9MqBgvcspm9DmraDx0mS PcSsBMCyrU0hxUBUnWBnQxCv5uiejTg5MJm9n0GIZo2gbAr6hX/Nw2psKKH7Li93f7t6 NuDA== X-Gm-Message-State: AFqh2kpAi/eTSeS+6rht6yDF7heCWPLoN0t3e8q6BkElLQNbmPy/cVrZ +Z9ynusMtbB4aKdoDvZik6oBW6fosTftEcfL X-Google-Smtp-Source: AMrXdXvheJDHcDMNIN7hvtKw0KqudVs7YWUrGsYtLiJAz+B1uyGIJSYhsqIbViNl5ZBSdt/mOowk9g== X-Received: by 2002:a17:902:ab1a:b0:192:9924:ce7e with SMTP id ik26-20020a170902ab1a00b001929924ce7emr25846518plb.55.1672893479162; Wed, 04 Jan 2023 20:37:59 -0800 (PST) Received: from chenghaoyang-low.c.googlers.com.com (46.165.189.35.bc.googleusercontent.com. [35.189.165.46]) by smtp.gmail.com with ESMTPSA id x23-20020a170902b41700b00188c5f0f9e9sm25015200plr.199.2023.01.04.20.37.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 20:37:58 -0800 (PST) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Thu, 5 Jan 2023 04:37:22 +0000 Message-Id: <20230105043726.679968-6-chenghaoyang@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230105043726.679968-1-chenghaoyang@google.com> References: <20230105043726.679968-1-chenghaoyang@google.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 5/9] libcamera: pipeline: virtual: Add MediaDeviceVirtual 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: , X-Patchwork-Original-From: Harvey Yang via libcamera-devel From: Harvey Yang Reply-To: Harvey Yang Cc: Harvey Yang , Harvey Yang Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a dummy MediaDeviceVirtual in PipelineHandlerVirtual::match, to avoid having no MediaDevice in the pipeline handler. Signed-off-by: Harvey Yang --- include/libcamera/internal/device_enumerator.h | 2 +- include/libcamera/internal/pipeline_handler.h | 2 +- src/libcamera/pipeline/virtual/virtual.cpp | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h index 87a2b5ce..e5eb3e94 100644 --- a/include/libcamera/internal/device_enumerator.h +++ b/include/libcamera/internal/device_enumerator.h @@ -41,13 +41,13 @@ public: virtual int init() = 0; virtual int enumerate() = 0; + void addDevice(std::unique_ptr media); std::shared_ptr search(const DeviceMatch &dm); Signal<> devicesAdded; protected: std::unique_ptr createDevice(const std::string &deviceNode); - void addDevice(std::unique_ptr media); void removeDevice(const std::string &deviceNode); private: diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index 1223b1cb..09004365 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -77,6 +77,7 @@ protected: virtual void releaseDevice(Camera *camera); CameraManager *manager_; + std::vector> mediaDevices_; private: void unlockMediaDevices(); @@ -87,7 +88,6 @@ private: void doQueueRequest(Request *request); void doQueueRequests(); - std::vector> mediaDevices_; std::vector> cameras_; std::queue waitingRequests_; diff --git a/src/libcamera/pipeline/virtual/virtual.cpp b/src/libcamera/pipeline/virtual/virtual.cpp index 09583b4e..6221196c 100644 --- a/src/libcamera/pipeline/virtual/virtual.cpp +++ b/src/libcamera/pipeline/virtual/virtual.cpp @@ -9,6 +9,7 @@ #include +#include "libcamera/internal/media_device_virtual.h" #include "libcamera/internal/pipeline_handler.h" namespace libcamera { @@ -41,6 +42,9 @@ public: int queueRequestDevice(Camera *camera, Request *request) override; bool match(DeviceEnumerator *enumerator) override; + +private: + std::shared_ptr mediaDeviceVirtual_; }; VirtualCameraConfiguration::VirtualCameraConfiguration() @@ -54,7 +58,7 @@ CameraConfiguration::Status VirtualCameraConfiguration::validate() } PipelineHandlerVirtual::PipelineHandlerVirtual(CameraManager *manager) - : PipelineHandler(manager) + : PipelineHandler(manager), mediaDeviceVirtual_(new MediaDeviceVirtual("virtual")) { } @@ -104,7 +108,8 @@ int PipelineHandlerVirtual::queueRequestDevice(Camera *camera, Request *request) bool PipelineHandlerVirtual::match(DeviceEnumerator *enumerator) { (void)enumerator; - return false; + mediaDevices_.push_back(mediaDeviceVirtual_); + return false; // Prevent infinite loops for now } REGISTER_PIPELINE_HANDLER(PipelineHandlerVirtual)