From patchwork Wed Jun 29 10:30:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 16428 X-Patchwork-Delegate: umang.jain@ideasonboard.com 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 4BFDFBE173 for ; Wed, 29 Jun 2022 10:30:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2972B6563F; Wed, 29 Jun 2022 12:30:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656498629; bh=cnT2I2kXHoViJJi+mchR8wLp6h1hHGjuDpJyjvEiPGw=; 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=wtWRWRcfSR16jTrXnfutsmtgeUDle4UDxmlcF4QI1Hyg3NuERPqRlLmzFmBgPNDYT cJKbnFCxWy3KOnrJ6Ylm0zgokA3qb+8IjYj4o9cpDSgWThyKEgsRIze4gFJD5oCH8k H9HkNYk8RreRrfQXcSl2BLx9DDrKD5vHneE477PMDHmJIYFkMr8I7ktimVOmnz7wmY EPOvlSqz0NX/wi4gdORfgmVD/TqGOOkm2f5+ucTFLdxiF4GW3e7fWm/tWrGsrQlaM0 RCXALvjZ4ObXxRiU3iC8ffdZqdE/nhOPpNf280mr620OafoCPlFtzb6nPYKi0WL7GJ dmz+wuCjLTqpg== Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A46DC60412 for ; Wed, 29 Jun 2022 12:30:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="gdxmm1yZ"; dkim-atps=neutral Received: by mail-pl1-x62b.google.com with SMTP id k14so13707881plh.4 for ; Wed, 29 Jun 2022 03:30:26 -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=SIwkgrFVZoMpv3fQMHYD/oCCOcCeDkunHhcLDNTInRI=; b=gdxmm1yZd8xdinJxTIzL6gpVEwejYIkBJE3TxScuriWB6H3MQtmtwy5vzfgmZW8UJo U7hGFoh72hk6jfIVE14FEtGGHqtk5e0uNir46nYZ/tLcF5FIzYkdmmj46gt4wJoo/Bd1 Hptice/40ig9C14a/LoG8FN0VADhAGpVNm5cw= 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=SIwkgrFVZoMpv3fQMHYD/oCCOcCeDkunHhcLDNTInRI=; b=qY6iodzFdNwFH/rEu5F6ueePr2Wu2eKh8hirkr1aLf0PIBRtHoeTbAYz+dhO8LNgzG ZFV8/0DSS/SSe9ngO+x7xNu1B2RxsdIMfKeFI7ketgh/Mz9pB371vne8AthA7nxVrPgR EQjX0tw+f3dVZVIyWUR9VY9GOzJjfYodX6pDJtzsxXZYtyqQ5RjXYSuksWOglYRg8TVk 19JhP3KPWn2xgT6SbhfPk+PTi2p7cylCAcd2dSMw0+bDO1kSG/bhnJNdn7S9f4XcvJzy USLyUlClBdUDGP1SdZ2eyzIx9wU7IXSF0+1Z25Rn86O7hW0yQ0etlbt3ek1AvemyGtN7 o3lA== X-Gm-Message-State: AJIora+8aJiBtCo/cON24qB7sjC1VGZRfVhIICGarpFKeonmGl1deEtl FOwx+10kEOWT1GQw1ooczKwQfZgjVJ9UCJSX X-Google-Smtp-Source: AGRyM1u7uyuYXadKQiykiZbedaA4/5Q8iLXlgcdAJ0o22OfSPY3yXtSYQCScJV4tp6ZXOum1Tqt0nQ== X-Received: by 2002:a17:902:bb8d:b0:168:e48d:86bc with SMTP id m13-20020a170902bb8d00b00168e48d86bcmr9881545pls.93.1656498624645; Wed, 29 Jun 2022 03:30:24 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (208.158.221.35.bc.googleusercontent.com. [35.221.158.208]) by smtp.gmail.com with ESMTPSA id jb4-20020a170903258400b00169071538a0sm10946059plb.267.2022.06.29.03.30.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 03:30:24 -0700 (PDT) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Wed, 29 Jun 2022 10:30:11 +0000 Message-Id: <20220629103018.4025635-3-chenghaoyang@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220629103018.4025635-1-chenghaoyang@google.com> References: <20220629103018.4025635-1-chenghaoyang@google.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/9] ipu3: 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index fd989e61..c943ee6a 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,14 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera) int PipelineHandlerIPU3::start(Camera *camera, [[maybe_unused]] const ControlList *controls) { + /* + * Enforce that only a single camera can be used at a time to use both + * ImgUs on the camera, so that StillCapture stream can adopt another + * set of configuration. + */ + if (inUseCamera_ && inUseCamera_ != camera) + return -EBUSY; + IPU3CameraData *data = cameraData(camera); CIO2Device *cio2 = &data->cio2_; ImgUDevice *imgu = data->imgu_; @@ -781,6 +791,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 +820,8 @@ error: freeBuffers(camera); LOG(IPU3, Error) << "Failed to start camera " << camera->id(); + inUseCamera_ = nullptr; + return ret; } @@ -826,6 +840,8 @@ void PipelineHandlerIPU3::stopDevice(Camera *camera) LOG(IPU3, Warning) << "Failed to stop camera " << camera->id(); freeBuffers(camera); + + inUseCamera_ = nullptr; } void IPU3CameraData::cancelPendingRequests()