From patchwork Thu Jul 9 13:28:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 8727 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 2C9BFBD792 for ; Thu, 9 Jul 2020 13:29:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EF5ED61221; Thu, 9 Jul 2020 15:29:20 +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="ozBd2D5b"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 13B7361184 for ; Thu, 9 Jul 2020 15:29:19 +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 33DA1525; Thu, 9 Jul 2020 15:29:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1594301358; bh=WJQYWIR9dO09qEADGTKWs1L3C0eGUVRmmPPR/vrM8bo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ozBd2D5bb2X68P0JucNyoptP2BV7BMxjyb7Oyanf85WLpp5z18uR+6qOVMkn1EbX0 M0qAuMnchMLxOoAZgMOKc1oeCH3CW+cM7YvRbv+M+kMnCcDzCZyRodYoUou2M3fWCP 4WXgLxRTWZlMQc3CZ/10D+L4CsWlfxSloLM0B0+g= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 9 Jul 2020 22:28:24 +0900 Message-Id: <20200709132835.112593-13-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200709132835.112593-1-paul.elder@ideasonboard.com> References: <20200709132835.112593-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 12/23] 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 v5: - simplify code Changes in v4: - fix stride and frameSize calculation - mention motivation in commit message New in v3 --- src/libcamera/pipeline/ipu3/ipu3.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index af51fb2..eb00eec 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -278,6 +278,12 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() << cfg.toString(); status = Adjusted; } + + const PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat); + bool packedRaw = info.colourEncoding == PixelFormatInfo::ColourEncodingRAW; + + cfg.stride = info.stride(cfg.size.width, 0, packedRaw ? 64 : 1); + cfg.frameSize = info.frameSize(cfg.size, packedRaw ? 64 : 1); } return status; @@ -495,21 +501,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; } }