[libcamera-devel,v4,03/16] libcamera: ipu3: Rationalize constant expressions names
diff mbox series

Message ID 20211014174208.50509-4-jacopo@jmondi.org
State Accepted
Headers show
Series
  • IPU3 control info update and HAL frame durations
Related show

Commit Message

Jacopo Mondi Oct. 14, 2021, 5:41 p.m. UTC
Following the previous patch that moved all the ImgU-related contants in
the ImgUDevice class namespace and that aligned their naming scheme to
the 'kNameOfConstant' scheme, apply the same changes to the other
components of the IPU3 pipeline handler.

Cosmetic change, no functional changes intended.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/libcamera/pipeline/ipu3/cio2.cpp |  6 +++---
 src/libcamera/pipeline/ipu3/cio2.h   |  2 +-
 src/libcamera/pipeline/ipu3/ipu3.cpp | 22 +++++++++++-----------
 3 files changed, 15 insertions(+), 15 deletions(-)

Comments

Paul Elder Oct. 18, 2021, 4:19 a.m. UTC | #1
Hi Jacopo,

On Thu, Oct 14, 2021 at 07:41:55PM +0200, Jacopo Mondi wrote:
> Following the previous patch that moved all the ImgU-related contants in
> the ImgUDevice class namespace and that aligned their naming scheme to
> the 'kNameOfConstant' scheme, apply the same changes to the other
> components of the IPU3 pipeline handler.
> 
> Cosmetic change, no functional changes intended.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  src/libcamera/pipeline/ipu3/cio2.cpp |  6 +++---
>  src/libcamera/pipeline/ipu3/cio2.h   |  2 +-
>  src/libcamera/pipeline/ipu3/ipu3.cpp | 22 +++++++++++-----------
>  3 files changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp
> index dc62ab197acb..59dda56bdd3d 100644
> --- a/src/libcamera/pipeline/ipu3/cio2.cpp
> +++ b/src/libcamera/pipeline/ipu3/cio2.cpp
> @@ -234,7 +234,7 @@ StreamConfiguration CIO2Device::generateConfiguration(Size size) const
>  
>  	cfg.size = sensorFormat.size;
>  	cfg.pixelFormat = mbusCodesToPixelFormat.at(sensorFormat.mbus_code);
> -	cfg.bufferCount = CIO2_BUFFER_COUNT;
> +	cfg.bufferCount = kBufferCount;
>  
>  	return cfg;
>  }
> @@ -338,11 +338,11 @@ int CIO2Device::exportBuffers(unsigned int count,
>  
>  int CIO2Device::start()
>  {
> -	int ret = output_->exportBuffers(CIO2_BUFFER_COUNT, &buffers_);
> +	int ret = output_->exportBuffers(kBufferCount, &buffers_);
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = output_->importBuffers(CIO2_BUFFER_COUNT);
> +	ret = output_->importBuffers(kBufferCount);
>  	if (ret)
>  		LOG(IPU3, Error) << "Failed to import CIO2 buffers";
>  
> diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h
> index 5fffe921f213..ba8f0052c5b3 100644
> --- a/src/libcamera/pipeline/ipu3/cio2.h
> +++ b/src/libcamera/pipeline/ipu3/cio2.h
> @@ -30,7 +30,7 @@ struct StreamConfiguration;
>  class CIO2Device
>  {
>  public:
> -	static constexpr unsigned int CIO2_BUFFER_COUNT = 4;
> +	static constexpr unsigned int kBufferCount = 4;
>  
>  	CIO2Device();
>  
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index 76fe9edb7dbc..11ac55c02681 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -39,10 +39,6 @@ namespace libcamera {
>  
>  LOG_DEFINE_CATEGORY(IPU3)
>  
> -static constexpr unsigned int IPU3_BUFFER_COUNT = 4;
> -static constexpr unsigned int IPU3_MAX_STREAMS = 3;
> -static constexpr Size IPU3ViewfinderSize(1280, 720);
> -
>  static const ControlInfoMap::Map IPU3Controls = {
>  	{ &controls::draft::PipelineDepth, ControlInfo(2, 3) },
>  };
> @@ -93,6 +89,9 @@ private:
>  class IPU3CameraConfiguration : public CameraConfiguration
>  {
>  public:
> +	static constexpr unsigned int kBufferCount = 4;
> +	static constexpr unsigned int kMaxStreams = 3;
> +
>  	IPU3CameraConfiguration(IPU3CameraData *data);
>  
>  	Status validate() override;
> @@ -119,6 +118,7 @@ class PipelineHandlerIPU3 : public PipelineHandler
>  {
>  public:
>  	static constexpr unsigned int V4L2_CID_IPU3_PIPE_MODE = 0x009819c1;
> +	static constexpr Size kViewfinderSize{ 1280, 720 };
>  
>  	enum IPU3PipeModes {
>  		IPU3PipeModeVideo = 0,
> @@ -218,8 +218,8 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
>  	combinedTransform_ = combined;
>  
>  	/* Cap the number of entries to the available streams. */
> -	if (config_.size() > IPU3_MAX_STREAMS) {
> -		config_.resize(IPU3_MAX_STREAMS);
> +	if (config_.size() > kMaxStreams) {
> +		config_.resize(kMaxStreams);
>  		status = Adjusted;
>  	}
>  
> @@ -356,7 +356,7 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
>  					      ImgUDevice::kOutputAlignHeight);
>  
>  			cfg->pixelFormat = formats::NV12;
> -			cfg->bufferCount = IPU3_BUFFER_COUNT;
> +			cfg->bufferCount = kBufferCount;
>  			cfg->stride = info.stride(cfg->size.width, 0, 1);
>  			cfg->frameSize = info.frameSize(cfg->size, 1);
>  
> @@ -444,7 +444,7 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,
>  				.alignedDownTo(ImgUDevice::kOutputMarginWidth,
>  					       ImgUDevice::kOutputMarginHeight);
>  			pixelFormat = formats::NV12;
> -			bufferCount = IPU3_BUFFER_COUNT;
> +			bufferCount = IPU3CameraConfiguration::kBufferCount;
>  			streamFormats[pixelFormat] = { { ImgUDevice::kOutputMinSize, size } };
>  
>  			break;
> @@ -469,11 +469,11 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,
>  			 * capped to the maximum sensor resolution and aligned
>  			 * to the ImgU output constraints.
>  			 */
> -			size = sensorResolution.boundedTo(IPU3ViewfinderSize)
> +			size = sensorResolution.boundedTo(kViewfinderSize)
>  					       .alignedDownTo(ImgUDevice::kOutputAlignWidth,
>  							      ImgUDevice::kOutputAlignHeight);
>  			pixelFormat = formats::NV12;
> -			bufferCount = IPU3_BUFFER_COUNT;
> +			bufferCount = IPU3CameraConfiguration::kBufferCount;
>  			streamFormats[pixelFormat] = { { ImgUDevice::kOutputMinSize, size } };
>  
>  			break;
> @@ -1004,7 +1004,7 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data)
>  	 * Either the smallest margin-aligned size larger than the viewfinder
>  	 * size or the adjusted sensor resolution.
>  	 */
> -	minSize = IPU3ViewfinderSize.grownBy({ 1, 1 })
> +	minSize = kViewfinderSize.grownBy({ 1, 1 })
>  		  .alignedUpTo(ImgUDevice::kOutputMarginWidth,
>  			       ImgUDevice::kOutputMarginHeight)
>  		  .boundedTo(minSize);
> -- 
> 2.33.0
>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp
index dc62ab197acb..59dda56bdd3d 100644
--- a/src/libcamera/pipeline/ipu3/cio2.cpp
+++ b/src/libcamera/pipeline/ipu3/cio2.cpp
@@ -234,7 +234,7 @@  StreamConfiguration CIO2Device::generateConfiguration(Size size) const
 
 	cfg.size = sensorFormat.size;
 	cfg.pixelFormat = mbusCodesToPixelFormat.at(sensorFormat.mbus_code);
-	cfg.bufferCount = CIO2_BUFFER_COUNT;
+	cfg.bufferCount = kBufferCount;
 
 	return cfg;
 }
@@ -338,11 +338,11 @@  int CIO2Device::exportBuffers(unsigned int count,
 
 int CIO2Device::start()
 {
-	int ret = output_->exportBuffers(CIO2_BUFFER_COUNT, &buffers_);
+	int ret = output_->exportBuffers(kBufferCount, &buffers_);
 	if (ret < 0)
 		return ret;
 
-	ret = output_->importBuffers(CIO2_BUFFER_COUNT);
+	ret = output_->importBuffers(kBufferCount);
 	if (ret)
 		LOG(IPU3, Error) << "Failed to import CIO2 buffers";
 
diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h
index 5fffe921f213..ba8f0052c5b3 100644
--- a/src/libcamera/pipeline/ipu3/cio2.h
+++ b/src/libcamera/pipeline/ipu3/cio2.h
@@ -30,7 +30,7 @@  struct StreamConfiguration;
 class CIO2Device
 {
 public:
-	static constexpr unsigned int CIO2_BUFFER_COUNT = 4;
+	static constexpr unsigned int kBufferCount = 4;
 
 	CIO2Device();
 
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 76fe9edb7dbc..11ac55c02681 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -39,10 +39,6 @@  namespace libcamera {
 
 LOG_DEFINE_CATEGORY(IPU3)
 
-static constexpr unsigned int IPU3_BUFFER_COUNT = 4;
-static constexpr unsigned int IPU3_MAX_STREAMS = 3;
-static constexpr Size IPU3ViewfinderSize(1280, 720);
-
 static const ControlInfoMap::Map IPU3Controls = {
 	{ &controls::draft::PipelineDepth, ControlInfo(2, 3) },
 };
@@ -93,6 +89,9 @@  private:
 class IPU3CameraConfiguration : public CameraConfiguration
 {
 public:
+	static constexpr unsigned int kBufferCount = 4;
+	static constexpr unsigned int kMaxStreams = 3;
+
 	IPU3CameraConfiguration(IPU3CameraData *data);
 
 	Status validate() override;
@@ -119,6 +118,7 @@  class PipelineHandlerIPU3 : public PipelineHandler
 {
 public:
 	static constexpr unsigned int V4L2_CID_IPU3_PIPE_MODE = 0x009819c1;
+	static constexpr Size kViewfinderSize{ 1280, 720 };
 
 	enum IPU3PipeModes {
 		IPU3PipeModeVideo = 0,
@@ -218,8 +218,8 @@  CameraConfiguration::Status IPU3CameraConfiguration::validate()
 	combinedTransform_ = combined;
 
 	/* Cap the number of entries to the available streams. */
-	if (config_.size() > IPU3_MAX_STREAMS) {
-		config_.resize(IPU3_MAX_STREAMS);
+	if (config_.size() > kMaxStreams) {
+		config_.resize(kMaxStreams);
 		status = Adjusted;
 	}
 
@@ -356,7 +356,7 @@  CameraConfiguration::Status IPU3CameraConfiguration::validate()
 					      ImgUDevice::kOutputAlignHeight);
 
 			cfg->pixelFormat = formats::NV12;
-			cfg->bufferCount = IPU3_BUFFER_COUNT;
+			cfg->bufferCount = kBufferCount;
 			cfg->stride = info.stride(cfg->size.width, 0, 1);
 			cfg->frameSize = info.frameSize(cfg->size, 1);
 
@@ -444,7 +444,7 @@  CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,
 				.alignedDownTo(ImgUDevice::kOutputMarginWidth,
 					       ImgUDevice::kOutputMarginHeight);
 			pixelFormat = formats::NV12;
-			bufferCount = IPU3_BUFFER_COUNT;
+			bufferCount = IPU3CameraConfiguration::kBufferCount;
 			streamFormats[pixelFormat] = { { ImgUDevice::kOutputMinSize, size } };
 
 			break;
@@ -469,11 +469,11 @@  CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,
 			 * capped to the maximum sensor resolution and aligned
 			 * to the ImgU output constraints.
 			 */
-			size = sensorResolution.boundedTo(IPU3ViewfinderSize)
+			size = sensorResolution.boundedTo(kViewfinderSize)
 					       .alignedDownTo(ImgUDevice::kOutputAlignWidth,
 							      ImgUDevice::kOutputAlignHeight);
 			pixelFormat = formats::NV12;
-			bufferCount = IPU3_BUFFER_COUNT;
+			bufferCount = IPU3CameraConfiguration::kBufferCount;
 			streamFormats[pixelFormat] = { { ImgUDevice::kOutputMinSize, size } };
 
 			break;
@@ -1004,7 +1004,7 @@  int PipelineHandlerIPU3::initControls(IPU3CameraData *data)
 	 * Either the smallest margin-aligned size larger than the viewfinder
 	 * size or the adjusted sensor resolution.
 	 */
-	minSize = IPU3ViewfinderSize.grownBy({ 1, 1 })
+	minSize = kViewfinderSize.grownBy({ 1, 1 })
 		  .alignedUpTo(ImgUDevice::kOutputMarginWidth,
 			       ImgUDevice::kOutputMarginHeight)
 		  .boundedTo(minSize);