[libcamera-devel,2/3] libcamera: pipeline: rkisp1: Use parameterized StreamConfiguration

Message ID 20200323232901.29169-3-kgupta@es.iitr.ac.in
State Superseded
Headers show
Series
  • Use StreamFormats in pipelines
Related show

Commit Message

Kaaira Gupta March 23, 2020, 11:29 p.m. UTC
Replace default constructor StreamConfiguration() by it's parameterized
counterpart  by using StreamFormats in generateConfiguration() in
rkisp1.

Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
---
 src/libcamera/pipeline/rkisp1/rkisp1.cpp | 39 ++++++++++++++++--------
 1 file changed, 27 insertions(+), 12 deletions(-)

Comments

Jacopo Mondi March 24, 2020, 8:12 a.m. UTC | #1
Hi Kaaira,

On Tue, Mar 24, 2020 at 04:59:00AM +0530, Kaaira Gupta wrote:
> Replace default constructor StreamConfiguration() by it's parameterized
> counterpart  by using StreamFormats in generateConfiguration() in
> rkisp1.

Looks good!

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
   j

>
> Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
> ---
>  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 39 ++++++++++++++++--------
>  1 file changed, 27 insertions(+), 12 deletions(-)
>
> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> index 04b0ed3..cfbfc9e 100644
> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> @@ -218,6 +218,21 @@ private:
>  	Camera *activeCamera_;
>  };
>
> +namespace {
> +
> +static const std::array<PixelFormat, 8> formats{
> +	PixelFormat(DRM_FORMAT_YUYV),
> +	PixelFormat(DRM_FORMAT_YVYU),
> +	PixelFormat(DRM_FORMAT_VYUY),
> +	PixelFormat(DRM_FORMAT_NV16),
> +	PixelFormat(DRM_FORMAT_NV61),
> +	PixelFormat(DRM_FORMAT_NV21),
> +	PixelFormat(DRM_FORMAT_NV12),
> +	/* \todo Add support for 8-bit greyscale to DRM formats */
> +};
> +
> +} /* namespace */
> +
>  RkISP1Frames::RkISP1Frames(PipelineHandler *pipe)
>  	: pipe_(dynamic_cast<PipelineHandlerRkISP1 *>(pipe))
>  {
> @@ -430,17 +445,6 @@ RkISP1CameraConfiguration::RkISP1CameraConfiguration(Camera *camera,
>
>  CameraConfiguration::Status RkISP1CameraConfiguration::validate()
>  {
> -	static const std::array<PixelFormat, 8> formats{
> -		PixelFormat(DRM_FORMAT_YUYV),
> -		PixelFormat(DRM_FORMAT_YVYU),
> -		PixelFormat(DRM_FORMAT_VYUY),
> -		PixelFormat(DRM_FORMAT_NV16),
> -		PixelFormat(DRM_FORMAT_NV61),
> -		PixelFormat(DRM_FORMAT_NV21),
> -		PixelFormat(DRM_FORMAT_NV12),
> -		/* \todo Add support for 8-bit greyscale to DRM formats */
> -	};
> -
>  	const CameraSensor *sensor = data_->sensor_;
>  	Status status = Valid;
>
> @@ -541,7 +545,18 @@ CameraConfiguration *PipelineHandlerRkISP1::generateConfiguration(Camera *camera
>  	if (roles.empty())
>  		return config;
>
> -	StreamConfiguration cfg{};
> +	std::map<PixelFormat, std::vector<SizeRange>> pixelformats;
> +	for (PixelFormat pixelformat : formats) {
> +		std::vector<SizeRange> sizes{
> +			/* Minimum and maximum capabilities of ISP output */
> +			SizeRange{ { 32, 16 }, { 4416, 3312 } }
> +		};
> +		pixelformats[pixelformat] = sizes;
> +	}
> +
> +	StreamFormats format(pixelformats);
> +	StreamConfiguration cfg(format);
> +
>  	cfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12);
>  	cfg.size = data->sensor_->resolution();
>
> --
> 2.17.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index 04b0ed3..cfbfc9e 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -218,6 +218,21 @@  private:
 	Camera *activeCamera_;
 };
 
+namespace {
+
+static const std::array<PixelFormat, 8> formats{
+	PixelFormat(DRM_FORMAT_YUYV),
+	PixelFormat(DRM_FORMAT_YVYU),
+	PixelFormat(DRM_FORMAT_VYUY),
+	PixelFormat(DRM_FORMAT_NV16),
+	PixelFormat(DRM_FORMAT_NV61),
+	PixelFormat(DRM_FORMAT_NV21),
+	PixelFormat(DRM_FORMAT_NV12),
+	/* \todo Add support for 8-bit greyscale to DRM formats */
+};
+
+} /* namespace */
+
 RkISP1Frames::RkISP1Frames(PipelineHandler *pipe)
 	: pipe_(dynamic_cast<PipelineHandlerRkISP1 *>(pipe))
 {
@@ -430,17 +445,6 @@  RkISP1CameraConfiguration::RkISP1CameraConfiguration(Camera *camera,
 
 CameraConfiguration::Status RkISP1CameraConfiguration::validate()
 {
-	static const std::array<PixelFormat, 8> formats{
-		PixelFormat(DRM_FORMAT_YUYV),
-		PixelFormat(DRM_FORMAT_YVYU),
-		PixelFormat(DRM_FORMAT_VYUY),
-		PixelFormat(DRM_FORMAT_NV16),
-		PixelFormat(DRM_FORMAT_NV61),
-		PixelFormat(DRM_FORMAT_NV21),
-		PixelFormat(DRM_FORMAT_NV12),
-		/* \todo Add support for 8-bit greyscale to DRM formats */
-	};
-
 	const CameraSensor *sensor = data_->sensor_;
 	Status status = Valid;
 
@@ -541,7 +545,18 @@  CameraConfiguration *PipelineHandlerRkISP1::generateConfiguration(Camera *camera
 	if (roles.empty())
 		return config;
 
-	StreamConfiguration cfg{};
+	std::map<PixelFormat, std::vector<SizeRange>> pixelformats;
+	for (PixelFormat pixelformat : formats) {
+		std::vector<SizeRange> sizes{
+			/* Minimum and maximum capabilities of ISP output */
+			SizeRange{ { 32, 16 }, { 4416, 3312 } }
+		};
+		pixelformats[pixelformat] = sizes;
+	}
+
+	StreamFormats format(pixelformats);
+	StreamConfiguration cfg(format);
+
 	cfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12);
 	cfg.size = data->sensor_->resolution();