[libcamera-devel,v2,4/5] libcamera: pipeline: simple: Store sensor resolution in configuration
diff mbox series

Message ID 20220612152311.8408-5-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: pipeline: simple: Support scaling on the camea sensor
Related show

Commit Message

Laurent Pinchart June 12, 2022, 3:23 p.m. UTC
When enumerating the supported configurations, store the corresponding
sensor resolution in the SimpleCameraData::Configuration structure and
use it when configuring the camera, instead of hardcoding the sensor
full resolution. This prepares for support of downscaling in the camera
sensor.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/pipeline/simple/simple.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Kieran Bingham June 15, 2022, 11:07 p.m. UTC | #1
Quoting Laurent Pinchart via libcamera-devel (2022-06-12 16:23:10)
> When enumerating the supported configurations, store the corresponding
> sensor resolution in the SimpleCameraData::Configuration structure and
> use it when configuring the camera, instead of hardcoding the sensor
> full resolution. This prepares for support of downscaling in the camera
> sensor.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Sounds reasonable too, ... So the final patch probably has the magic I'm
looking for...

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/libcamera/pipeline/simple/simple.cpp | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
> index 3c90bdec60e0..8c48162d7ff0 100644
> --- a/src/libcamera/pipeline/simple/simple.cpp
> +++ b/src/libcamera/pipeline/simple/simple.cpp
> @@ -225,6 +225,7 @@ public:
>  
>         struct Configuration {
>                 uint32_t code;
> +               Size sensorSize;
>                 PixelFormat captureFormat;
>                 Size captureSize;
>                 std::vector<PixelFormat> outputFormats;
> @@ -542,6 +543,7 @@ void SimpleCameraData::tryPipeline(unsigned int code, const Size &size)
>  
>                 Configuration config;
>                 config.code = code;
> +               config.sensorSize = size;
>                 config.captureFormat = pixelFormat;
>                 config.captureSize = format.size;
>  
> @@ -943,7 +945,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
>         const SimpleCameraData::Configuration *pipeConfig = config->pipeConfig();
>         V4L2SubdeviceFormat format{};
>         format.mbus_code = pipeConfig->code;
> -       format.size = data->sensor_->resolution();
> +       format.size = pipeConfig->sensorSize;
>  
>         ret = data->setupFormats(&format, V4L2Subdevice::ActiveFormat);
>         if (ret < 0)
> -- 
> Regards,
> 
> Laurent Pinchart
>
Dorota Czaplejewicz June 21, 2022, 5:18 p.m. UTC | #2
On Sun, 12 Jun 2022 18:23:10 +0300
Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote:

> When enumerating the supported configurations, store the corresponding
> sensor resolution in the SimpleCameraData::Configuration structure and
> use it when configuring the camera, instead of hardcoding the sensor
> full resolution. This prepares for support of downscaling in the camera
> sensor.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/libcamera/pipeline/simple/simple.cpp | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
> index 3c90bdec60e0..8c48162d7ff0 100644
> --- a/src/libcamera/pipeline/simple/simple.cpp
> +++ b/src/libcamera/pipeline/simple/simple.cpp
> @@ -225,6 +225,7 @@ public:
>  
>  	struct Configuration {
>  		uint32_t code;
> +		Size sensorSize;
>  		PixelFormat captureFormat;
>  		Size captureSize;
>  		std::vector<PixelFormat> outputFormats;
> @@ -542,6 +543,7 @@ void SimpleCameraData::tryPipeline(unsigned int code, const Size &size)
>  
>  		Configuration config;
>  		config.code = code;
> +		config.sensorSize = size;
>  		config.captureFormat = pixelFormat;
>  		config.captureSize = format.size;
>  
> @@ -943,7 +945,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
>  	const SimpleCameraData::Configuration *pipeConfig = config->pipeConfig();
>  	V4L2SubdeviceFormat format{};
>  	format.mbus_code = pipeConfig->code;
> -	format.size = data->sensor_->resolution();
> +	format.size = pipeConfig->sensorSize;

Does it not always equal pipeConfig->captureSize?

It's not an issue with this series, but captureSize confuses me. outputSize seems clearer, as it is only relevant for the scaler.

--Dorota
>  
>  	ret = data->setupFormats(&format, V4L2Subdevice::ActiveFormat);
>  	if (ret < 0)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index 3c90bdec60e0..8c48162d7ff0 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -225,6 +225,7 @@  public:
 
 	struct Configuration {
 		uint32_t code;
+		Size sensorSize;
 		PixelFormat captureFormat;
 		Size captureSize;
 		std::vector<PixelFormat> outputFormats;
@@ -542,6 +543,7 @@  void SimpleCameraData::tryPipeline(unsigned int code, const Size &size)
 
 		Configuration config;
 		config.code = code;
+		config.sensorSize = size;
 		config.captureFormat = pixelFormat;
 		config.captureSize = format.size;
 
@@ -943,7 +945,7 @@  int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
 	const SimpleCameraData::Configuration *pipeConfig = config->pipeConfig();
 	V4L2SubdeviceFormat format{};
 	format.mbus_code = pipeConfig->code;
-	format.size = data->sensor_->resolution();
+	format.size = pipeConfig->sensorSize;
 
 	ret = data->setupFormats(&format, V4L2Subdevice::ActiveFormat);
 	if (ret < 0)