From patchwork Tue May 19 16:55:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3822 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C264C603DA for ; Tue, 19 May 2020 18:55:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="DdCi33me"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 280C230C for ; Tue, 19 May 2020 18:55:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1589907357; bh=YKKB8tqYb6shN8PKwNsZe7H9E3mCT+v/KmyajrpYwuk=; h=From:To:Subject:Date:From; b=DdCi33meQnJRHDjgIt70UwWrFUK4aLrk1pOGoR3+QJ4skOU1uLYayL/kcc84C6EMy DkMfaV1M05Jn/ZoMNHvhpWQHM9EY/qjjqL/IEXs74TuqDc+rW7x/DYP288c9fxtO3G 5MOs1nYD396BJ35oaR7XlthAi2jjaXFULUPNfreE= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 19 May 2020 19:55:41 +0300 Message-Id: <20200519165543.30465-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/3] libcamera: pipeline: simple: Add stride support 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-List-Received-Date: Tue, 19 May 2020 16:55:58 -0000 Report the stride when configuring the camera. The stride is retrieved from the capture device first, and overridden by the converter if used. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/pipeline/simple/converter.cpp | 13 ++++++++----- src/libcamera/pipeline/simple/converter.h | 4 ++-- src/libcamera/pipeline/simple/simple.cpp | 5 +++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp index 02443e7f78ed..7a9d67b37624 100644 --- a/src/libcamera/pipeline/simple/converter.cpp +++ b/src/libcamera/pipeline/simple/converter.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "libcamera/internal/log.h" #include "libcamera/internal/media_device.h" @@ -93,14 +94,14 @@ std::vector SimpleConverter::formats(PixelFormat input) } int SimpleConverter::configure(PixelFormat inputFormat, - PixelFormat outputFormat, const Size &size) + StreamConfiguration *cfg) { V4L2DeviceFormat format; int ret; V4L2PixelFormat videoFormat = m2m_->output()->toV4L2PixelFormat(inputFormat); format.fourcc = videoFormat; - format.size = size; + format.size = cfg->size; ret = m2m_->output()->setFormat(&format); if (ret < 0) { @@ -109,7 +110,7 @@ int SimpleConverter::configure(PixelFormat inputFormat, return ret; } - if (format.fourcc != videoFormat || format.size != size) { + if (format.fourcc != videoFormat || format.size != cfg->size) { LOG(SimplePipeline, Error) << "Input format not supported"; return -EINVAL; @@ -119,7 +120,7 @@ int SimpleConverter::configure(PixelFormat inputFormat, * Set the pixel format on the output, the size is identical to the * input as we don't support scaling. */ - videoFormat = m2m_->capture()->toV4L2PixelFormat(outputFormat); + videoFormat = m2m_->capture()->toV4L2PixelFormat(cfg->pixelFormat); format.fourcc = videoFormat; ret = m2m_->capture()->setFormat(&format); @@ -129,12 +130,14 @@ int SimpleConverter::configure(PixelFormat inputFormat, return ret; } - if (format.fourcc != videoFormat || format.size != size) { + if (format.fourcc != videoFormat || format.size != cfg->size) { LOG(SimplePipeline, Error) << "Output format not supported"; return -EINVAL; } + cfg->stride = format.planes[0].bpl; + return 0; } diff --git a/src/libcamera/pipeline/simple/converter.h b/src/libcamera/pipeline/simple/converter.h index a33071fa8578..0beb96a55d5b 100644 --- a/src/libcamera/pipeline/simple/converter.h +++ b/src/libcamera/pipeline/simple/converter.h @@ -20,6 +20,7 @@ namespace libcamera { class FrameBuffer; class MediaDevice; struct Size; +struct StreamConfiguration; class V4L2M2MDevice; class SimpleConverter @@ -33,8 +34,7 @@ public: std::vector formats(PixelFormat input); - int configure(PixelFormat inputFormat, PixelFormat outputFormat, - const Size &size); + int configure(PixelFormat inputFormat, StreamConfiguration *cfg); int exportBuffers(unsigned int count, std::vector> *buffers); diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 2565190082c8..68595bc29726 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -549,12 +549,13 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) return -EINVAL; } + cfg.stride = captureFormat.planes[0].bpl; + /* Configure the converter if required. */ useConverter_ = config->needConversion(); if (useConverter_) { - int ret = converter_->configure(pipeConfig.pixelFormat, - cfg.pixelFormat, cfg.size); + int ret = converter_->configure(pipeConfig.pixelFormat, &cfg); if (ret < 0) { LOG(SimplePipeline, Error) << "Unable to configure converter";