From patchwork Wed Jul 1 12:30:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 8532 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 E9C3ABF415 for ; Wed, 1 Jul 2020 12:27:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C675F60C62; Wed, 1 Jul 2020 14:27:24 +0200 (CEST) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6DEA860CAE for ; Wed, 1 Jul 2020 14:27:22 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id E6DB51C0003; Wed, 1 Jul 2020 12:27:21 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Jul 2020 14:30:26 +0200 Message-Id: <20200701123036.51922-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200701123036.51922-1-jacopo@jmondi.org> References: <20200701123036.51922-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 05/15] libcamera: ipu3: Report StreamFormats 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Report StreamFormats associated to each StreamConfiguration generated by the IPU3 pipeline handler. The StreamFormats are generated differently for RAW and processed streams, with the former using the sensor enumerated resolutions and the latter using a continuous range of sizes constructed by matching the sensor capabilities with the platform constraints. Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- src/libcamera/pipeline/ipu3/ipu3.cpp | 47 +++++++++++++++++++++------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index cd18c6f31023..ed2360347fb4 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -33,6 +33,9 @@ LOG_DEFINE_CATEGORY(IPU3) static constexpr unsigned int IPU3_BUFFER_COUNT = 4; static constexpr unsigned int IPU3_MAX_STREAMS = 3; +static constexpr unsigned int IPU3_OUTPUT_MAX_WIDTH = 4480; +static constexpr unsigned int IPU3_OUTPUT_MAX_HEIGHT = 34004; +static const Size minIPU3OutputSize = { 2, 2 }; class IPU3CameraData : public CameraData { @@ -295,15 +298,19 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera, { IPU3CameraData *data = cameraData(camera); IPU3CameraConfiguration *config = new IPU3CameraConfiguration(camera, data); + CIO2Device *cio2 = &data->cio2_; if (roles.empty()) return config; - Size sensorResolution = data->cio2_.sensor()->resolution(); + Size sensorResolution = cio2->sensor()->resolution(); unsigned int rawCount = 0; unsigned int outCount = 0; for (const StreamRole role : roles) { - StreamConfiguration cfg = {}; + std::map> streamFormats; + unsigned int bufferCount; + PixelFormat pixelFormat; + Size size; switch (role) { case StreamRole::StillCapture: @@ -311,19 +318,29 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera, * Use the sensor resolution adjusted to respect the * ImgU output alignement contraints. */ - cfg.pixelFormat = formats::NV12; - cfg.size = sensorResolution; - cfg.size.width &= ~7; - cfg.size.height &= ~3; - cfg.bufferCount = IPU3_BUFFER_COUNT; + pixelFormat = formats::NV12; + size.width = std::min(sensorResolution.width, + IPU3_OUTPUT_MAX_WIDTH); + size.height = std::min(sensorResolution.height, + IPU3_OUTPUT_MAX_HEIGHT); + size.width &= ~7; + size.height &= ~3; + bufferCount = IPU3_BUFFER_COUNT; + streamFormats[pixelFormat] = { { minIPU3OutputSize, size } }; outCount++; break; case StreamRole::StillCaptureRaw: { - cfg = data->cio2_.generateConfiguration(sensorResolution); - cfg.bufferCount = 1; + StreamConfiguration cio2Config = + cio2->generateConfiguration(sensorResolution); + pixelFormat = cio2Config.pixelFormat; + size = cio2Config.size; + bufferCount = cio2Config.bufferCount; + + for (const PixelFormat &format : cio2->formats()) + streamFormats[format] = cio2->sizes(); rawCount++; @@ -339,9 +356,10 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera, */ unsigned int width = std::min(1280U, sensorResolution.width); unsigned int height = std::min(720U, sensorResolution.height); - cfg.size = { width & ~7, height & ~3 }; - cfg.pixelFormat = formats::NV12; - cfg.bufferCount = IPU3_BUFFER_COUNT; + size = { width & ~7, height & ~3 }; + pixelFormat = formats::NV12; + bufferCount = IPU3_BUFFER_COUNT; + streamFormats[pixelFormat] = { { minIPU3OutputSize, size } }; outCount++; @@ -361,6 +379,11 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera, return nullptr; } + StreamFormats formats(streamFormats); + StreamConfiguration cfg(formats); + cfg.size = size; + cfg.pixelFormat = pixelFormat; + cfg.bufferCount = bufferCount; config->addConfiguration(cfg); }