[libcamera-devel,v2,09/20] libcamera: camera: Zero streams before validate()

Message ID 20200709084128.5316-10-jacopo@jmondi.org
State Accepted
Headers show
Series
  • libcamera: ipu3: Rework configuration
Related show

Commit Message

Jacopo Mondi July 9, 2020, 8:41 a.m. UTC
The current implementation of the Camera::configure() method zeroes the
stream pointers assigned to the StreamConfiguration items before calling
the pipeline handler configure() operation, just after the
CameraConfiguration has been validated.

This discards the stream assignment performed at pipeline hander
validation time, requiring platforms that need to perform that early
assignment to maintain the association in place with custom data
structures.

To allow pipeline handlers to use StreamConfiguration::setStream() at
validate() time, zero the stream assignment before calling validate().

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/camera.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Niklas Söderlund July 9, 2020, 1:32 p.m. UTC | #1
Hi Jacopo,

Thanks for your work.

On 2020-07-09 10:41:17 +0200, Jacopo Mondi wrote:
> The current implementation of the Camera::configure() method zeroes the
> stream pointers assigned to the StreamConfiguration items before calling
> the pipeline handler configure() operation, just after the
> CameraConfiguration has been validated.
> 
> This discards the stream assignment performed at pipeline hander
> validation time, requiring platforms that need to perform that early
> assignment to maintain the association in place with custom data
> structures.
> 
> To allow pipeline handlers to use StreamConfiguration::setStream() at
> validate() time, zero the stream assignment before calling validate().
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/libcamera/camera.cpp | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> index 69a1b4428e3f..ca88c48b2830 100644
> --- a/src/libcamera/camera.cpp
> +++ b/src/libcamera/camera.cpp
> @@ -753,6 +753,9 @@ int Camera::configure(CameraConfiguration *config)
>  	if (ret < 0)
>  		return ret;
>  
> +	for (auto it : *config)
> +		it.setStream(nullptr);
> +
>  	if (config->validate() != CameraConfiguration::Valid) {
>  		LOG(Camera, Error)
>  			<< "Can't configure camera with invalid configuration";
> @@ -763,7 +766,6 @@ int Camera::configure(CameraConfiguration *config)
>  
>  	for (unsigned int index = 0; index < config->size(); ++index) {
>  		StreamConfiguration &cfg = config->at(index);
> -		cfg.setStream(nullptr);
>  		msg << " (" << index << ") " << cfg.toString();
>  	}
>  
> -- 
> 2.27.0
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart July 10, 2020, 8:57 a.m. UTC | #2
Hi Jacopo,

Thank you for the patch.

On Thu, Jul 09, 2020 at 10:41:17AM +0200, Jacopo Mondi wrote:
> The current implementation of the Camera::configure() method zeroes the
> stream pointers assigned to the StreamConfiguration items before calling
> the pipeline handler configure() operation, just after the
> CameraConfiguration has been validated.
> 
> This discards the stream assignment performed at pipeline hander
> validation time, requiring platforms that need to perform that early
> assignment to maintain the association in place with custom data
> structures.
> 
> To allow pipeline handlers to use StreamConfiguration::setStream() at
> validate() time, zero the stream assignment before calling validate().
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

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

> ---
>  src/libcamera/camera.cpp | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> index 69a1b4428e3f..ca88c48b2830 100644
> --- a/src/libcamera/camera.cpp
> +++ b/src/libcamera/camera.cpp
> @@ -753,6 +753,9 @@ int Camera::configure(CameraConfiguration *config)
>  	if (ret < 0)
>  		return ret;
>  
> +	for (auto it : *config)
> +		it.setStream(nullptr);
> +
>  	if (config->validate() != CameraConfiguration::Valid) {
>  		LOG(Camera, Error)
>  			<< "Can't configure camera with invalid configuration";
> @@ -763,7 +766,6 @@ int Camera::configure(CameraConfiguration *config)
>  
>  	for (unsigned int index = 0; index < config->size(); ++index) {
>  		StreamConfiguration &cfg = config->at(index);
> -		cfg.setStream(nullptr);
>  		msg << " (" << index << ") " << cfg.toString();
>  	}
>

Patch

diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index 69a1b4428e3f..ca88c48b2830 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -753,6 +753,9 @@  int Camera::configure(CameraConfiguration *config)
 	if (ret < 0)
 		return ret;
 
+	for (auto it : *config)
+		it.setStream(nullptr);
+
 	if (config->validate() != CameraConfiguration::Valid) {
 		LOG(Camera, Error)
 			<< "Can't configure camera with invalid configuration";
@@ -763,7 +766,6 @@  int Camera::configure(CameraConfiguration *config)
 
 	for (unsigned int index = 0; index < config->size(); ++index) {
 		StreamConfiguration &cfg = config->at(index);
-		cfg.setStream(nullptr);
 		msg << " (" << index << ") " << cfg.toString();
 	}