[v2,05/14] libcamera: v4l2_subdevice: Drop V4L2SubdeviceFormat::bitsPerPixel()
diff mbox series

Message ID 20240315001613.2033-6-laurent.pinchart@ideasonboard.com
State Accepted
Commit 4c82481fc4622c2e78ec9f426bcad27728bb7079
Headers show
Series
  • libcamera: Prepare for new camera sensor class
Related show

Commit Message

Laurent Pinchart March 15, 2024, 12:16 a.m. UTC
The V4L2SubdeviceFormat::bitsPerPixel() function is just a wrapper
around a MediaBusFormatInfo lookup. It made sense when the
MediaBusFormatInfo class was not exposed outside of the compilation
unit, but is now redundant. Drop it and use MediaBusFormatInfo in the
only caller.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 include/libcamera/internal/v4l2_subdevice.h |  1 -
 src/libcamera/camera_sensor.cpp             |  3 ++-
 src/libcamera/v4l2_subdevice.cpp            | 10 ----------
 3 files changed, 2 insertions(+), 12 deletions(-)

Comments

Kieran Bingham March 15, 2024, 1:05 a.m. UTC | #1
Quoting Laurent Pinchart (2024-03-15 00:16:04)
> The V4L2SubdeviceFormat::bitsPerPixel() function is just a wrapper
> around a MediaBusFormatInfo lookup. It made sense when the
> MediaBusFormatInfo class was not exposed outside of the compilation
> unit, but is now redundant. Drop it and use MediaBusFormatInfo in the
> only caller.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> ---
>  include/libcamera/internal/v4l2_subdevice.h |  1 -
>  src/libcamera/camera_sensor.cpp             |  3 ++-
>  src/libcamera/v4l2_subdevice.cpp            | 10 ----------
>  3 files changed, 2 insertions(+), 12 deletions(-)
> 
> diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h
> index c9aa90e00ec8..a87981341d75 100644
> --- a/include/libcamera/internal/v4l2_subdevice.h
> +++ b/include/libcamera/internal/v4l2_subdevice.h
> @@ -66,7 +66,6 @@ struct V4L2SubdeviceFormat {
>         std::optional<ColorSpace> colorSpace;
>  
>         const std::string toString() const;
> -       uint8_t bitsPerPixel() const;
>  };
>  
>  std::ostream &operator<<(std::ostream &out, const V4L2SubdeviceFormat &f);
> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
> index 0ef78d9c8b0a..55c9c74b10c2 100644
> --- a/src/libcamera/camera_sensor.cpp
> +++ b/src/libcamera/camera_sensor.cpp
> @@ -1060,7 +1060,8 @@ int CameraSensor::sensorInfo(IPACameraSensorInfo *info) const
>         ret = subdev_->getFormat(pad_, &format);
>         if (ret)
>                 return ret;
> -       info->bitsPerPixel = format.bitsPerPixel();
> +
> +       info->bitsPerPixel = MediaBusFormatInfo::info(format.mbus_code).bitsPerPixel;

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

>         info->outputSize = format.size;
>  
>         std::optional<int32_t> cfa = properties_.get(properties::draft::ColorFilterArrangement);
> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
> index a508cef4dcbb..84ec93154951 100644
> --- a/src/libcamera/v4l2_subdevice.cpp
> +++ b/src/libcamera/v4l2_subdevice.cpp
> @@ -793,16 +793,6 @@ const std::string V4L2SubdeviceFormat::toString() const
>         return ss.str();
>  }
>  
> -/**
> - * \brief Retrieve the number of bits per pixel for the V4L2 subdevice format
> - * \return The number of bits per pixel for the format, or 0 if the format is
> - * not supported
> - */
> -uint8_t V4L2SubdeviceFormat::bitsPerPixel() const
> -{
> -       return MediaBusFormatInfo::info(mbus_code).bitsPerPixel;
> -}
> -
>  /**
>   * \brief Insert a text representation of a V4L2SubdeviceFormat into an output
>   * stream
> -- 
> Regards,
> 
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h
index c9aa90e00ec8..a87981341d75 100644
--- a/include/libcamera/internal/v4l2_subdevice.h
+++ b/include/libcamera/internal/v4l2_subdevice.h
@@ -66,7 +66,6 @@  struct V4L2SubdeviceFormat {
 	std::optional<ColorSpace> colorSpace;
 
 	const std::string toString() const;
-	uint8_t bitsPerPixel() const;
 };
 
 std::ostream &operator<<(std::ostream &out, const V4L2SubdeviceFormat &f);
diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index 0ef78d9c8b0a..55c9c74b10c2 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -1060,7 +1060,8 @@  int CameraSensor::sensorInfo(IPACameraSensorInfo *info) const
 	ret = subdev_->getFormat(pad_, &format);
 	if (ret)
 		return ret;
-	info->bitsPerPixel = format.bitsPerPixel();
+
+	info->bitsPerPixel = MediaBusFormatInfo::info(format.mbus_code).bitsPerPixel;
 	info->outputSize = format.size;
 
 	std::optional<int32_t> cfa = properties_.get(properties::draft::ColorFilterArrangement);
diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
index a508cef4dcbb..84ec93154951 100644
--- a/src/libcamera/v4l2_subdevice.cpp
+++ b/src/libcamera/v4l2_subdevice.cpp
@@ -793,16 +793,6 @@  const std::string V4L2SubdeviceFormat::toString() const
 	return ss.str();
 }
 
-/**
- * \brief Retrieve the number of bits per pixel for the V4L2 subdevice format
- * \return The number of bits per pixel for the format, or 0 if the format is
- * not supported
- */
-uint8_t V4L2SubdeviceFormat::bitsPerPixel() const
-{
-	return MediaBusFormatInfo::info(mbus_code).bitsPerPixel;
-}
-
 /**
  * \brief Insert a text representation of a V4L2SubdeviceFormat into an output
  * stream