From patchwork Tue Aug 2 10:29:41 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: 16906 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 0E077C3276 for ; Tue, 2 Aug 2022 10:30:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B963D63322; Tue, 2 Aug 2022 12:30:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659436202; bh=fftKRZ8Zftn+0drHl4Az7GPNsW4B5X+NpZrUkBSDbxI=; 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=PvvSWWqK+tzi/qpTx/RMS5FXXn5iHWKD52gfjAePxaDDqtCY9F2ehY3hk/IzWx6+u PknWHi73A6c5TdZzEuceoljVB9ZCpEnKB7pdTKm3XmIG/qdJy4zzUFjZeTirN8BERE jqIoNgfb2Tng9IojTT9NZTnteGk3ScN0xheGi41er6aoSvpKBBP/Gnnouj+Jqy8OHe PM6tBDccUTCOaFtRMk+z+EjE08Zot1wGa95P47AOLBA5fhN2yPVwNYWq/o6ZpKaWhT ENPWAbsMiyOgUqFuea/Y0194dxS9pmdyvK3WZjVaqZC9ItXZsdlcfCtfE+ZCMHMbtr 9HNGWGPo3ATDQ== Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AAA9C63322 for ; Tue, 2 Aug 2022 12:30:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="deV0JFxB"; dkim-atps=neutral Received: by mail-pg1-x52b.google.com with SMTP id bh13so11996353pgb.4 for ; Tue, 02 Aug 2022 03:30:00 -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=h4dGYpA4iZvZ1T7cXsIMETguxzq6lHaCODno5/mhFrM=; b=deV0JFxBMPSokv+92/1Ohs2evFpGWohbbh3CmbGR+RbHJLQ/jpHkyrPQhVo1XnIiMR hQbby1y6GaSJ9KHdfpdtxl2YuuhM+OFvI9d/Oi5txvZ3mfzJL5+7mYny2oFVqG3rWwW6 kyLUe/x6rJuWqVyb1IDyX6QUARf8VpGjLaMlY= 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=h4dGYpA4iZvZ1T7cXsIMETguxzq6lHaCODno5/mhFrM=; b=NtHC1E49Th3dRydUHynU6rYfG5HcI5k8d4+uxO3kUX7Tq9i3eWgT5pipd9n9FbIijA amiCEfBH5WnAL9JZz7u3dCElJ4xdIVhoIyNCT31mXIXWULhvmp2vP+DUCbVrl2nVU5rz QUBg4g04DIODKYVVy085K5Uuz4UWqie0ci9igTHvBfh3vdpRihXbHXAllssR1HMUno/G xVqgwpNMuAdPaqVkYhRoTMVxUt/jxtugqMh+hQ19l5Nhe8O7qE8o+ruSJLuUC/cyzxLI lq/Vj7tjhVTQU5fuK11PB+cn+fZ9MZimNQhj+ocl7CzJBNreLsWC38lU+YjhYa/+dDo1 kV5g== X-Gm-Message-State: AJIora9PJw82Jx6+g605kONkXW4kRB16/wYgWFYkJ2bLpSe0DToCeeKI s7ISRP9diypfYBnA3xFz8SCCGDaiORjBMA== X-Google-Smtp-Source: AGRyM1t7oMKaEhBfm9L7TA5ovfeS2V+MLAl9AlMT2LRL21LQmcFN2IfxanKGdVQDMsUyvkg3WinVDg== X-Received: by 2002:a63:211b:0:b0:41b:8f73:576d with SMTP id h27-20020a63211b000000b0041b8f73576dmr16199913pgh.106.1659436199823; Tue, 02 Aug 2022 03:29:59 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (231.137.80.34.bc.googleusercontent.com. [34.80.137.231]) by smtp.gmail.com with ESMTPSA id t15-20020a170902e84f00b0016db88f69a2sm1955128plg.141.2022.08.02.03.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 03:29:59 -0700 (PDT) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Tue, 2 Aug 2022 10:29:41 +0000 Message-Id: <20220802102943.3221109-8-chenghaoyang@google.com> X-Mailer: git-send-email 2.37.1.455.g008518b4e5-goog In-Reply-To: <20220802102943.3221109-1-chenghaoyang@google.com> References: <20220802102943.3221109-1-chenghaoyang@google.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 7/9] ipu3: 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 | 56 ++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 73f361f8..f8101c6c 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -254,8 +254,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_) { @@ -264,16 +266,34 @@ 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) { + /* + * If only the StillCapture stream is requested, it cannot be + * supported natively, as we need a video stream that enables + * the 3A. Therefore, use video snapshot instead. + */ + stillCount = 0; + videoCount = 1; + 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 @@ -316,6 +336,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. @@ -380,18 +403,35 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() cfg->stride = info.stride(cfg->size.width, 0, 1); cfg->frameSize = info.frameSize(cfg->size, 1); + if (cfg->streamRole == StreamRole::StillCapture) { + ASSERT(stillCount == 1); + 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() @@ -415,7 +455,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: "