From patchwork Wed Jul 8 13:44:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 8683 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 1E1D2BD792 for ; Wed, 8 Jul 2020 13:45:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E149B6113A; Wed, 8 Jul 2020 15:45:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jeWkBP+g"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1CDA3610B2 for ; Wed, 8 Jul 2020 15:45:00 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A260551B; Wed, 8 Jul 2020 15:44:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1594215899; bh=GJxUpRt86Lep1STgHoHbsBtzVBV7BXPJyXTrsNluO1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jeWkBP+g2UhOyJHK8ONnEcgrWyaQtgs6ijYCA82tG067VwH48q9C43ZehrBktsnHL ZGm/MKCzrXAVdgF4HDhajfbUcjkA8126LFTe3sMFI5KTXxzwGgrW1/RFP0GL96nFZA USLNs6V2avfaoD914VV6ewFhL/PDAVQYIdKmOqxU= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 8 Jul 2020 22:44:10 +0900 Message-Id: <20200708134417.67747-15-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200708134417.67747-1-paul.elder@ideasonboard.com> References: <20200708134417.67747-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 14/21] libcamera: ipu3: Fill stride and frameSize at config validation 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" Fill the stride and frameSize fields of the StreamConfiguration at configuration validation time instead of at camera configuration time. This allows applications to get the stride when trying a configuration without modifying the active configuration of the camera. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v4: - fix stride and frameSize calculation - mention motivation in commit message New in v3 --- src/libcamera/pipeline/ipu3/ipu3.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 00559ce..4a2d924 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -278,6 +278,21 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() << cfg.toString(); status = Adjusted; } + + const PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat); + bool packedRaw = info.packed && + info.colourEncoding == PixelFormatInfo::ColourEncodingRAW; + + if (packedRaw) { + cfg.stride = info.stride(cfg.size.width, 0, 64); + cfg.frameSize = cfg.stride * cfg.size.height; + } else { + cfg.stride = info.stride(cfg.size.width, 0); + std::array strides; + for (unsigned int j = 0; j < 3; j++) + strides[i] = info.stride(cfg.size.width, i, packedRaw ? 64 : 0); + cfg.frameSize = info.frameSize(cfg.size, strides); + } } return status; @@ -495,21 +510,13 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) if (ret) return ret; - cfg.stride = outputFormat.planes[0].bpl; outActive = true; } else if (stream == vfStream) { ret = imgu->configureViewfinder(cfg, &outputFormat); if (ret) return ret; - cfg.stride = outputFormat.planes[0].bpl; vfActive = true; - } else { - /* - * The RAW stream is configured as part of the CIO2 and - * no configuration is needed for the ImgU. - */ - cfg.stride = cio2Format.planes[0].bpl; } }