From patchwork Thu May 12 10:32:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 15898 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 CF257C326C for ; Thu, 12 May 2022 10:33:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0C65065641; Thu, 12 May 2022 12:33:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652351590; bh=wukPARUiUSFLdffEzZ5nRpJD5im1hAxRriQA2ITD1Wo=; 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=vmU44JqLm7Dx+nwZTSyFSNSAo6Oqy6eP1K9PCm2Zb3DyGv47E6e/jgS5J6o151z6Q 8duq1jxdlWvmSGS+OW8jMFPivW/VuUzwNlhahyf2u6nUh3wwor1uPqHKtCpMb0cLtf uhhQmyAfRhnX3aEgHCwtNTiDxY/qkkRlBBjRDnAiLAD9Sk13gMYPNVtikI0oS+gTP3 35VDOXEMNCkPrROo4/29ZWC8lhLo2tpktC3N9bzTdxkB/ENUg1tTAeBBbRmn5zG2+S N7QBYYd1ZSZtTUuXk/28W4AaFeiCvO6o16joEDB7h3YE5N0VQgbD1AYyJyrltxOFOE JEbjiI2unCgbA== Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 53D8C6049E for ; Thu, 12 May 2022 12:33:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="m6YhqHrw"; dkim-atps=neutral Received: by mail-pj1-x1030.google.com with SMTP id cq17-20020a17090af99100b001dc0386cd8fso4485950pjb.5 for ; Thu, 12 May 2022 03:33:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WfSb3RCwf0H+pQuNDVNprdxG0GnEl0+4yWxd1rNIr2s=; b=m6YhqHrwMucCYo1a1/16vsGpwREEBhSGG4qQO2tFYO2MKcPgkMuiSDUprqt5mGYA41 gWTEYY/DiMppbFvIgd57o+SHy8i+wlyMpLN2nh3G2MPs+c7I/FgIX2wpjgFGRjsewqmi RlrXHz/0YXUtFT2c4gZzmD/ordmmcRCSZXvzI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WfSb3RCwf0H+pQuNDVNprdxG0GnEl0+4yWxd1rNIr2s=; b=kzxHz1dqIu4Mb0Y7eMuGtbNI85duPcXEGnTBVHRh161WPbfSlUGj/y0h6Z3CJgxcD7 QlaHCljTqlKyIe7bNMlR6wfBaE0NMQpdPfabc1XEtHEh7dJ/UxR9Iq9no62CqH7PGa6O dvYFgs9Uv2cC6FSWrvsr4NRjT5R64kqkv6RkhUdeotR5tFwDFFFcud1ljoNAhF+3wrRo 0BVxfbRrYKN86Kff0/Pgil5tfZ69kC3nATu3gKmRVAncNWK44Vhy3/zSXcJKFlJGAN4m 1S20ZL5LU+OYHAHLNx6iYWBU59rDlyktlyWOfmkMwZUe/L3R/XgyjmHAiKNi/GtMjRWy G4yw== X-Gm-Message-State: AOAM532KsrJyISIAqKXO8XYKOs+a3IWwopy4KtBGXZFI+jbgAXUGsl75 B4qrQy64LlGODi7HgPGyUcYspG2sDCf13ZVl X-Google-Smtp-Source: ABdhPJxqeSsgi61fGU6pt9az3QNZiR5TXmH09IhGILKa75wV/NLKGhtPLFl0YilBshP0g28li0ULUw== X-Received: by 2002:a17:902:ce92:b0:15e:9601:dc02 with SMTP id f18-20020a170902ce9200b0015e9601dc02mr28740393plg.79.1652351586314; Thu, 12 May 2022 03:33:06 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with ESMTPSA id t19-20020a62d153000000b005087c23ad8dsm3402219pfl.0.2022.05.12.03.33.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 03:33:05 -0700 (PDT) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Thu, 12 May 2022 10:32:52 +0000 Message-Id: <20220512103258.324339-3-chenghaoyang@google.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220512103258.324339-1-chenghaoyang@google.com> References: <20220512103258.324339-1-chenghaoyang@google.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/8] Allow only one camera being started 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Harvey Yang As we hardly have use cases/applications that need both cameras at the same time, this patch adds a rule that only one camera can be started one time. This also allows the following patches that use both imgus to process frames from one single camera. Signed-off-by: Harvey Yang --- src/libcamera/pipeline/ipu3/ipu3.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index fd989e61..111ba053 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -166,6 +166,8 @@ private: MediaDevice *cio2MediaDev_; MediaDevice *imguMediaDev_; + Camera *inUseCamera_ = nullptr; + std::vector ipaBuffers_; }; @@ -765,6 +767,10 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera) int PipelineHandlerIPU3::start(Camera *camera, [[maybe_unused]] const ControlList *controls) { + // Deny second camera being started. + if (inUseCamera_ && inUseCamera_ != camera) + return -1; + IPU3CameraData *data = cameraData(camera); CIO2Device *cio2 = &data->cio2_; ImgUDevice *imgu = data->imgu_; @@ -781,6 +787,8 @@ int PipelineHandlerIPU3::start(Camera *camera, [[maybe_unused]] const ControlLis if (ret) return ret; + inUseCamera_ = camera; + ret = data->ipa_->start(); if (ret) goto error; @@ -808,6 +816,8 @@ error: freeBuffers(camera); LOG(IPU3, Error) << "Failed to start camera " << camera->id(); + inUseCamera_ = nullptr; + return ret; } @@ -826,6 +836,8 @@ void PipelineHandlerIPU3::stopDevice(Camera *camera) LOG(IPU3, Warning) << "Failed to stop camera " << camera->id(); freeBuffers(camera); + + inUseCamera_ = nullptr; } void IPU3CameraData::cancelPendingRequests()