From patchwork Wed Mar 15 10:22:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 18405 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 B4CDEBD80A for ; Wed, 15 Mar 2023 10:23:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5020262713; Wed, 15 Mar 2023 11:23:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678875796; bh=CentXDF8+nDFGMuylFGBwlDbJfTcAFRpcnll8D9Wb+o=; 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=DzIJ/DhLrVVh9FbH6ePFpnc9GTJb1P66mRD87/wv9a04Q2SRgQpKWM5muYFxxqS0b i7ae+5PkufKJa4UQ3N5eqyNebO0J/bemyf3jVBfs6geDdQr+Bbr9ouSD3LRHs8NtU8 g49NsZvpxPeSPKRAcyX01Dlrry4t3+US+wrRsOwXM5CcgmiAiuAGgrCTeTvotqz8xC H7wKtkYEqrdSLdsJGVXCao1KKUEq0uUs4Q/UNRLdYoc8CzYJBRcflUVPaqqyyzPC6y Om096cODvjPDC1PiLE0bNjYLkG9YGvsRpsyBJHjrYgdJSFHI4E8CUiEwfnvPc6PGOo PzKdX5+RGpcqQ== Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 272F361ED2 for ; Wed, 15 Mar 2023 11:23:11 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="JDtR1mDw"; dkim-atps=neutral Received: by mail-pl1-x633.google.com with SMTP id k2so11614723pll.8 for ; Wed, 15 Mar 2023 03:23:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1678875789; 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=pAw5c9JTwxEQpNQNeVzTS98+ZCH/QfhvpXbHNCRsR4c=; b=JDtR1mDwaan7B9e71NUX5c5pcGwCLlyaW1WKQeLlflDYkpN1duroB8H0PVQnA7E+n5 fpE3W2bNmDsVsK8MPAUcC+YKnRTPYrbbLmpjEACWbYXWlvR0R4y0JpUClsrqbsF+v99p BhqJULgTd7nYoELOPlIkJz1m0kGgR+sLUdAqI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678875789; 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=pAw5c9JTwxEQpNQNeVzTS98+ZCH/QfhvpXbHNCRsR4c=; b=rUJjL+sVLz47aqyO72jBiWHYR3sm3hb9LD0tRyB3fiMp5NTS8cif2Fip6LoZCW/IME aXeYTMzHtRJUHS3xMFOS+miMEagRCzaKnQO56MwEC7fxbkgl6DVTZqYAc9Uaaw0ayARb rOszNJudZZxze+s66mCl85+cepmL3i7J+iIE+k2ScPp2/IAFz+v/n0XJJY+mKYh7Rdk2 fRpnaVbP3Y3MdtQBOX+S1Qez//LIu8jeRtDVdIDWRQqt9RhmTWKxMpCjA/5e1mBTuEIi A3ccQYIbTF7Pfw7GqHcr0cvXyqJEse/yiCahqLgRyjp2x/59ZObGdXwiDisz3F79T2Om d3pg== X-Gm-Message-State: AO0yUKV8b7pwpnR0Qp0uGWV2/nCLQqmf89bXTUR5HdOkoEBrLPeL9bPk h5RucrP2IV1rv1iTG12XPbhBsxcTF2VishhyWes= X-Google-Smtp-Source: AK7set+p7u5yWRPw11mucEfZMscO9uOzOWiQlFwujhXK/r1sjhMWMF8MB+6n/BG49mlsRhcC+xwd0Q== X-Received: by 2002:a17:90b:17c4:b0:234:e0c:caaa with SMTP id me4-20020a17090b17c400b002340e0ccaaamr42338943pjb.6.1678875789470; Wed, 15 Mar 2023 03:23:09 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (112.157.221.35.bc.googleusercontent.com. [35.221.157.112]) by smtp.gmail.com with ESMTPSA id f11-20020a17090274cb00b001a0450da45csm3262786plt.185.2023.03.15.03.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 03:23:09 -0700 (PDT) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Wed, 15 Mar 2023 10:22:57 +0000 Message-Id: <20230315102300.2265491-4-chenghaoyang@google.com> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog In-Reply-To: <20230315102300.2265491-1-chenghaoyang@google.com> References: <20230315102300.2265491-1-chenghaoyang@google.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 3/6] libcamera: pipeline: virtual: Create a Camera 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" Create a VirtualCameraData inheriting from the CameraData to handle camera specific data, and use it to create and register the camera with the CameraManager. This can now be tested to see that the camera becomes available to applications: """ build/src/apps/cam/cam -l [550:47:04.505850647] [1969734] INFO IPAManager ipa_manager.cpp:143 libcamera is not installed. Adding ... to the IPA search path [550:47:04.509307667] [1969734] INFO Camera camera_manager.cpp:293 libcamera v0.0.1+54-55fecb4d-dirty (2022-12-01T05:47:11+00:00) Available cameras: 1: (Virtual0) """ Signed-off-by: Harvey Yang --- src/libcamera/pipeline/virtual/virtual.cpp | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/virtual/virtual.cpp b/src/libcamera/pipeline/virtual/virtual.cpp index 09583b4e..1d66a60e 100644 --- a/src/libcamera/pipeline/virtual/virtual.cpp +++ b/src/libcamera/pipeline/virtual/virtual.cpp @@ -9,12 +9,26 @@ #include +#include "libcamera/internal/camera.h" #include "libcamera/internal/pipeline_handler.h" namespace libcamera { LOG_DEFINE_CATEGORY(VIRTUAL) +class VirtualCameraData : public Camera::Private +{ +public: + VirtualCameraData(PipelineHandler *pipe) + : Camera::Private(pipe) + { + } + + ~VirtualCameraData() = default; + + Stream stream_; +}; + class VirtualCameraConfiguration : public CameraConfiguration { public: @@ -104,7 +118,15 @@ int PipelineHandlerVirtual::queueRequestDevice(Camera *camera, Request *request) bool PipelineHandlerVirtual::match(DeviceEnumerator *enumerator) { (void)enumerator; - return false; + + std::unique_ptr data = std::make_unique(this); + /* Create and register the camera. */ + std::set streams{ &data->stream_ }; + const std::string id = "Virtual0"; + std::shared_ptr camera = Camera::create(std::move(data), id, streams); + registerCamera(std::move(camera)); + + return false; // Prevent infinite loops for now } REGISTER_PIPELINE_HANDLER(PipelineHandlerVirtual)