[libcamera-devel,v3,1/4] libcamera: rkisp1: Generate config using main path
diff mbox series

Message ID 20230307114804.42291-2-jacopo.mondi@ideasonboard.com
State Superseded
Headers show
Series
  • libcamera: rkisp1: Fix generateConfiguration
Related show

Commit Message

Jacopo Mondi March 7, 2023, 11:48 a.m. UTC
The generateConfiguration() implementation in the Rockchip RkISP1
pipeline handler uses by default the self path (if available) for
the Viewfinder and VideoRecording StreamRoles.

The validate() implementation, at the contrary, prefers using the main
path, when available, for all streams.

As the self-path is limited in output resolution to 1920x1920,
generating a configuration using the self path limits the maximum
stream size to 1920x1920, while higher resolutions can be obtained by
using the main path.

Align the generateConfiguration() implementation to the validate() one
by using the main path by default if available.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=180
Reported-by: libcamera@luigi311.com
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
---
 src/libcamera/pipeline/rkisp1/rkisp1.cpp | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

Comments

Laurent Pinchart March 19, 2023, 7:51 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Tue, Mar 07, 2023 at 12:48:01PM +0100, Jacopo Mondi via libcamera-devel wrote:
> The generateConfiguration() implementation in the Rockchip RkISP1
> pipeline handler uses by default the self path (if available) for
> the Viewfinder and VideoRecording StreamRoles.
> 
> The validate() implementation, at the contrary, prefers using the main
> path, when available, for all streams.
> 
> As the self-path is limited in output resolution to 1920x1920,
> generating a configuration using the self path limits the maximum
> stream size to 1920x1920, while higher resolutions can be obtained by
> using the main path.
> 
> Align the generateConfiguration() implementation to the validate() one
> by using the main path by default if available.
>
> Bug: https://bugs.libcamera.org/show_bug.cgi?id=180
> Reported-by: libcamera@luigi311.com
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

There's a reason we prefer the self path for some of the roles, as
explained in the git history:

commit 921c0cdc6a0c486c9b53af5746b1cce6a2501b3e
Author: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Date:   Thu Aug 13 01:51:21 2020 +0200

    libcamera: pipeline: rkisp1: Expose self path stream

    Expose the self stream to applications and prefers it for the viewfinder
    and video roles as it can be extended to produce RGB. Keep preferring
    the main path for still capture as it could be extended to support RAW
    formats which makes most sense for still capture.

    With this change the self path becomes available to applications and a
    camera backed by this pipeline can produce two streams simultaneously.

    Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
    Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
    Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Switching to the main path unconditionally, while making higher
resolutions available, prevents capturing RGB formats.

I'm fine with this patch, but it shows we have an API problem as we can
expose the capabilities of the device correctly to the application.
Could you start thinking how this could be improved ?

> ---
>  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> index 096c9cca3a0a..ebc9bef8688a 100644
> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> @@ -647,23 +647,19 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,
>  	 * first stream and use it for all streams.
>  	 */
>  	std::optional<ColorSpace> colorSpace;
> -
>  	bool mainPathAvailable = true;
> -	bool selfPathAvailable = data->selfPath_;
>  
>  	for (const StreamRole role : roles) {
> -		bool useMainPath;
> +		bool useMainPath = mainPathAvailable;

You can drop the useMainPath variable and use mainPathAvailable in the
only location where useMainPath is still used. With this change,

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

>  
>  		switch (role) {
>  		case StreamRole::StillCapture:
> -			useMainPath = mainPathAvailable;
>  			/* JPEG encoders typically expect sYCC. */
>  			if (!colorSpace)
>  				colorSpace = ColorSpace::Sycc;
>  			break;
>  
>  		case StreamRole::Viewfinder:
> -			useMainPath = !selfPathAvailable;
>  			/*
>  			 * sYCC is the YCbCr encoding of sRGB, which is commonly
>  			 * used by displays.
> @@ -673,7 +669,6 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,
>  			break;
>  
>  		case StreamRole::VideoRecording:
> -			useMainPath = !selfPathAvailable;
>  			/* Rec. 709 is a good default for HD video recording. */
>  			if (!colorSpace)
>  				colorSpace = ColorSpace::Rec709;
> @@ -686,7 +681,6 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,
>  				return nullptr;
>  			}
>  
> -			useMainPath = true;
>  			colorSpace = ColorSpace::Raw;
>  			break;
>  
> @@ -703,7 +697,6 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,
>  			mainPathAvailable = false;
>  		} else {
>  			path = data->selfPath_;
> -			selfPathAvailable = false;
>  		}
>  
>  		StreamConfiguration cfg =

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index 096c9cca3a0a..ebc9bef8688a 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -647,23 +647,19 @@  PipelineHandlerRkISP1::generateConfiguration(Camera *camera,
 	 * first stream and use it for all streams.
 	 */
 	std::optional<ColorSpace> colorSpace;
-
 	bool mainPathAvailable = true;
-	bool selfPathAvailable = data->selfPath_;
 
 	for (const StreamRole role : roles) {
-		bool useMainPath;
+		bool useMainPath = mainPathAvailable;
 
 		switch (role) {
 		case StreamRole::StillCapture:
-			useMainPath = mainPathAvailable;
 			/* JPEG encoders typically expect sYCC. */
 			if (!colorSpace)
 				colorSpace = ColorSpace::Sycc;
 			break;
 
 		case StreamRole::Viewfinder:
-			useMainPath = !selfPathAvailable;
 			/*
 			 * sYCC is the YCbCr encoding of sRGB, which is commonly
 			 * used by displays.
@@ -673,7 +669,6 @@  PipelineHandlerRkISP1::generateConfiguration(Camera *camera,
 			break;
 
 		case StreamRole::VideoRecording:
-			useMainPath = !selfPathAvailable;
 			/* Rec. 709 is a good default for HD video recording. */
 			if (!colorSpace)
 				colorSpace = ColorSpace::Rec709;
@@ -686,7 +681,6 @@  PipelineHandlerRkISP1::generateConfiguration(Camera *camera,
 				return nullptr;
 			}
 
-			useMainPath = true;
 			colorSpace = ColorSpace::Raw;
 			break;
 
@@ -703,7 +697,6 @@  PipelineHandlerRkISP1::generateConfiguration(Camera *camera,
 			mainPathAvailable = false;
 		} else {
 			path = data->selfPath_;
-			selfPathAvailable = false;
 		}
 
 		StreamConfiguration cfg =