[libcamera-devel,v2,01/13] libcamera: pipeline: rkisp1: Set number of planes based on format

Message ID 20200914142149.63857-2-niklas.soderlund@ragnatech.se
State Accepted
Headers show
Series
  • libcamera: pipeline: rkisp1: Extend to support two streams
Related show

Commit Message

Niklas Söderlund Sept. 14, 2020, 2:21 p.m. UTC
The RkISP1 pipeline originally only supported NV formats which have 2
planes. When support for YUV formats was added the plane count on the
output format was not made to reflect this. Instead of hard coding the
plane count to 2 fetch the number of planes from the format information.

Reported-by: Jacopo Mondi <jacopo@jmondi.org>
Fixes: 2b1a908b5222e263 ("libcamera: camera: Add a validation API to the CameraConfiguration class")
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/libcamera/pipeline/rkisp1/rkisp1.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Sept. 15, 2020, 12:27 a.m. UTC | #1
Hi Niklas,

Thank you for the patch.

On Mon, Sep 14, 2020 at 04:21:37PM +0200, Niklas Söderlund wrote:
> The RkISP1 pipeline originally only supported NV formats which have 2
> planes. When support for YUV formats was added the plane count on the
> output format was not made to reflect this. Instead of hard coding the
> plane count to 2 fetch the number of planes from the format information.
> 
> Reported-by: Jacopo Mondi <jacopo@jmondi.org>
> Fixes: 2b1a908b5222e263 ("libcamera: camera: Add a validation API to the CameraConfiguration class")
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> index a6fc3b8e36f3b00a..009d190d3ec828f0 100644
> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> @@ -667,10 +667,11 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)
>  
>  	LOG(RkISP1, Debug) << "Resizer output pad configured with " << format.toString();
>  
> +	const PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat);
>  	V4L2DeviceFormat outputFormat = {};
>  	outputFormat.fourcc = video_->toV4L2PixelFormat(cfg.pixelFormat);
>  	outputFormat.size = cfg.size;
> -	outputFormat.planesCount = 2;
> +	outputFormat.planesCount = info.numPlanes();
>  
>  	ret = video_->setFormat(&outputFormat);
>  	if (ret)

Patch

diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index a6fc3b8e36f3b00a..009d190d3ec828f0 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -667,10 +667,11 @@  int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)
 
 	LOG(RkISP1, Debug) << "Resizer output pad configured with " << format.toString();
 
+	const PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat);
 	V4L2DeviceFormat outputFormat = {};
 	outputFormat.fourcc = video_->toV4L2PixelFormat(cfg.pixelFormat);
 	outputFormat.size = cfg.size;
-	outputFormat.planesCount = 2;
+	outputFormat.planesCount = info.numPlanes();
 
 	ret = video_->setFormat(&outputFormat);
 	if (ret)