From patchwork Thu May 26 08:27:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 16051 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 A2A30C3256 for ; Thu, 26 May 2022 08:27:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B322B65667; Thu, 26 May 2022 10:27:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653553672; bh=ABgfGQ/ElEe+i40usmKjEuyVAwo8ycwZk/ueid1QkgM=; 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=b9jE1JjQeboIMNO0JPSLQp7RW1lcpqL3aabEVfxBSCL/3P/g/XoQLq0bC0y1FY5qM dR2del/f2mVL18hmBFADxwQ8v70mLiFKRMQVMj7SPHTWOjc45to59xf0Hrjo1NUiAu WdFGg/0wg/CoLsagfhVMa5zXOTc872EHokF2lD0WQjbdfp3LKxYnB9NwGjp9c/1rDu CuvM1CJdtwdpO1B9ZCpxJ15Yjap2Nn4eqGeQN0uPhsse5jICCbHxm/T+WXQ65RnsSS Hfe5RvUSVIrZHhmPNoOzRAHGD8zdm39nnJSCFSSJXlVoOSGK3fvX0TDweZZnI0OlMJ hRkaMqpYMH+dw== Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B3B956565D for ; Thu, 26 May 2022 10:27:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="bD5sbJi7"; dkim-atps=neutral Received: by mail-pj1-x102b.google.com with SMTP id q92-20020a17090a17e500b001e0817e77f6so3794171pja.5 for ; Thu, 26 May 2022 01:27:49 -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=7I54rMUuKWDVxcfwPnpOucKfcZsO9xgIQyAJBV3cSkg=; b=bD5sbJi7RkPAsAQFopJH4ay0kCF/jrITjA7NGbp5GT0uJ61av5xtflEy4SUIwsmLDB MmWPT9zPQ7sbq4VCXrrZxatvL1vKtqkWQ1Af4JYXfpdBEU+yP6//tarmv+G2uUa/WtAM +wU8AvCEwgjQ/JBp739SkCY9NRw5MBNdqRutg= 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=7I54rMUuKWDVxcfwPnpOucKfcZsO9xgIQyAJBV3cSkg=; b=mwV5le7wvFeNNxr7Q8ZJHedwYqeVtMGsrEMIhnPjvnB+Oh06hFs92xZFSRDAoRCXpZ ehKoquDuvbnLXG/1vZv67oy5rKLx4WcmCJBexGnm54UlYgPDotrK6X8NIviXAH2hzcvp zwBMp4JYZZF7Qg5hu0HDUt4JAE4GoYny0WEGyHvS4U4CaMFaHJjO3fqHCmUKWxQO0Xg2 Zkq2mh2VtW1gLxMKDZmpWDxyQFG6zTvrRtMCp3O8BcOoABYNe1iyFqjL480aAR8VRm19 fef6aBIetzyiLOLTPCbLZMRuEDqCpU1UZq7+cenzLh8IYLxgmd+vtDSp0v1rS0Fz0Kiz vDKg== X-Gm-Message-State: AOAM531okNrWc50NjntFY4BIGhia2TU5PY8iMcN+avZ3c1t3tSW+j6vY 0mlb0dzPv+jDz7xFsVeJguBHmwVL6vTrXgRi X-Google-Smtp-Source: ABdhPJxPbTlPe1zKARFtM+3NQx+s/mN/GqEzY9GZJMTtwvb5sP3LEv/mdXYkHQC21ZU9MrGcniqcjw== X-Received: by 2002:a17:90b:1095:b0:1e0:ccaa:e5f0 with SMTP id gj21-20020a17090b109500b001e0ccaae5f0mr1432742pjb.198.1653553667863; Thu, 26 May 2022 01:27:47 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (21.160.199.104.bc.googleusercontent.com. [104.199.160.21]) by smtp.gmail.com with ESMTPSA id m2-20020a170902bb8200b0016191b843e2sm834429pls.235.2022.05.26.01.27.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 01:27:47 -0700 (PDT) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Thu, 26 May 2022 08:27:30 +0000 Message-Id: <20220526082737.1081262-3-chenghaoyang@google.com> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog In-Reply-To: <20220526082737.1081262-1-chenghaoyang@google.com> References: <20220526082737.1081262-1-chenghaoyang@google.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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()