From patchwork Thu May 12 10:32:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-Hao Yang X-Patchwork-Id: 15903 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 D54B0C3256 for ; Thu, 12 May 2022 10:33:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 78BEA65657; Thu, 12 May 2022 12:33:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652351598; bh=gCQstSjvJGwHXaHOtpruSN974DmXKSWgDVgsIcbWObM=; 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=QJkaXTUlmnhT7pJQ9MQBQAa5JEhY9JAxWOydprmN6elcW/Pt0r42dktTj+/8b1z6Y P3gk02HRhMBeJLUHf9tWfZXMuAyuGmjDMDZGSIx9JJRBIaEly2c4MbVJCdgJqQKuO4 RzFcbgSA0zBMfk6Q2d/E/dwyx7T0z6Y+0w+W0UfLT2CR0bFdQ9qIRUvSPw+XL6c4F9 X0DEx64pNlVt13JdMDE5OcDWtDSLq8CPjmAXi9GfIRA+TSz25gUa2/LhDJ6xG8oXeB VYNjK5aI9S23NvgxoteAH34U2r8nlaT9y8FQpeRA4Tvi/FdHQhR/kDnw7cwVUluGEY IksFIKlwm2SeA== Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DE2CF65656 for ; Thu, 12 May 2022 12:33:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Z6iwdeDj"; dkim-atps=neutral Received: by mail-pg1-x52f.google.com with SMTP id 31so4206527pgp.8 for ; Thu, 12 May 2022 03:33:16 -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=xiU6As+WxCHaLY/jIx5QcwNyTIeEOCwcYi0xBHtZjc8=; b=Z6iwdeDj4LGvMxWwAwAdatiBlkL/Tkh8AWtHfkzxHfxYcNyVid4jJvCnB3467RAXYp b6wvDm5a8jJokQQRshX+/bRggU/pdsxZ8NVacHHI8uoFwvKMuz/Vs2ojqyVDaHfUGAyI cliuW2RDyhB1Xo3e5Tb6ga3QgKsEL1v3GzJP0= 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=xiU6As+WxCHaLY/jIx5QcwNyTIeEOCwcYi0xBHtZjc8=; b=pM5J4vpby9nkqRrnDYO54mYPxdRlHRn//euXznY4+wvhVyVqc3LwB5SpX/SqRpKZm4 YF+Pto4V3o604iHtxIvVCCVHg++XLz1cEgwm5d+z1EgWpl3B9A6P/bQECOBqjHIrOoe5 O/UWs/chs8obf3fkSeFW7Jguy+UWU+J3hvWESBE9mL/XwnsjDbbX+3UT/Z/YTmyQOaCx KTqoRKoBpTiZnucJOVFmUFY0SKolZ4R0uDa73OZH6YHrkDaBCFEMLSdYuvYnSWZpYT6s qy9UmeWjfRJXGVCTyy84A+rueHWPZ/cBgxcGrDP227288JqcCnbvtZM+4IFOs+Sx8RdC MbUw== X-Gm-Message-State: AOAM5329GSbEZOwkFbuyKyy+QuVi8uVIj77/nUMJ7DaSoABZRTMAij51 YH2yCl3KJzZOgrcgY1Mu925Ke2yLpoHbD87S X-Google-Smtp-Source: ABdhPJy2ShlBnvl7e4feG4KJLkasRLVIV3Vlt+L6FWqrLiV+3SkSTgObLq5NGAHH5hG2C2G2x7IO8g== X-Received: by 2002:a63:dc42:0:b0:3c5:e187:572 with SMTP id f2-20020a63dc42000000b003c5e1870572mr24829895pgj.82.1652351595016; Thu, 12 May 2022 03:33:15 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 03:33:14 -0700 (PDT) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Thu, 12 May 2022 10:32:57 +0000 Message-Id: <20220512103258.324339-8-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 7/8] Assign |outCaptureStream| to StillCapture configuration 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: Cheng-Hao Yang Reply-To: Harvey Yang Cc: Harvey Yang , Harvey Yang Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When StillCapture and other non-raw configurations are requested, assigns |outCaptureStream| instead of |outStream| to the StillCapture configuration. Signed-off-by: Harvey Yang --- src/libcamera/pipeline/ipu3/ipu3.cpp | 51 +++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 9498b1b0..94aeebf3 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -257,8 +257,10 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() * \todo Clarify the IF and BDS margins requirements. */ unsigned int rawCount = 0; - unsigned int yuvCount = 0; + unsigned int videoCount = 0; + unsigned int stillCount = 0; Size maxYuvSize; + Size maxVideoSize; Size rawSize; for (const StreamConfiguration &cfg : config_) { @@ -267,16 +269,30 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) { rawCount++; rawSize.expandTo(cfg.size); + } else if (cfg.streamRole == StreamRole::StillCapture) { + if (stillCount != 0) + return Invalid; + + stillCount++; + maxYuvSize.expandTo(cfg.size); } else { - yuvCount++; + videoCount++; maxYuvSize.expandTo(cfg.size); + maxVideoSize.expandTo(cfg.size); } } - if (rawCount > 1 || yuvCount > 2) { + if (videoCount == 0 && stillCount == 1) { + stillCount = 0; + videoCount = 1; + onlyStillCapture_ = true; + maxVideoSize.expandTo(maxYuvSize); + } + + if (rawCount > 1 || videoCount > 2) { LOG(IPU3, Debug) << "Camera configuration not supported"; return Invalid; - } else if (rawCount && !yuvCount) { + } else if (rawCount && !stillCount && !videoCount) { /* * Disallow raw-only camera configuration. Currently, ImgU does * not get configured for raw-only streams and has early return @@ -319,6 +335,9 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() ImgUDevice::Pipe pipe{}; pipe.input = cio2Configuration_.size; + ImgUDevice::Pipe pipe1{}; + pipe1.input = cio2Configuration_.size; + /* * Adjust the configurations if needed and assign streams while * iterating them. @@ -383,18 +402,34 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() cfg->stride = info.stride(cfg->size.width, 0, 1); cfg->frameSize = info.frameSize(cfg->size, 1); + if (stillCount == 1 && cfg->streamRole == StreamRole::StillCapture) { + LOG(IPU3, Debug) << "Assigned " + << cfg->toString() + << " to the imgu1 main output"; + cfg->setStream(const_cast(&data_->outCaptureStream_)); + + pipe1.main = cfg->size; + pipe1.viewfinder = pipe1.main; + + pipeConfig1_ = data_->imgu1_->calculatePipeConfig(&pipe1); + if (pipeConfig1_.isNull()) { + LOG(IPU3, Error) << "Failed to calculate pipe configuration: " + << "unsupported resolutions."; + return Invalid; + } /* * Use the main output stream in case only one stream is * requested or if the current configuration is the one * with the maximum YUV output size. */ - if (mainOutputAvailable && - (originalCfg.size == maxYuvSize || yuvCount == 1)) { + } else if (mainOutputAvailable && + (originalCfg.size == maxVideoSize || + videoCount == 1)) { cfg->setStream(const_cast(&data_->outStream_)); mainOutputAvailable = false; pipe.main = cfg->size; - if (yuvCount == 1) + if (videoCount == 1) pipe.viewfinder = pipe.main; LOG(IPU3, Debug) << "Assigned " << cfg->toString() @@ -418,7 +453,7 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() } /* Only compute the ImgU configuration if a YUV stream has been requested. */ - if (yuvCount) { + if (videoCount) { pipeConfig0_ = data_->imgu0_->calculatePipeConfig(&pipe); if (pipeConfig0_.isNull()) { LOG(IPU3, Error) << "Failed to calculate pipe configuration: "