[libcamera-devel,4/7] libcamera: v4l2_device: Rename plane format fields

Message ID 20190201154248.15006-5-jacopo@jmondi.org
State Accepted
Headers show
Series
  • libcamera: v4l2_device: Address comments for s/g_fmt
Related show

Commit Message

Jacopo Mondi Feb. 1, 2019, 3:42 p.m. UTC
Rename the number of valid plane formats to 'planesCount' and the actual
per-plane size information array to 'planes'.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/include/v4l2_device.h |  4 ++--
 src/libcamera/v4l2_device.cpp       | 29 ++++++++++++++---------------
 2 files changed, 16 insertions(+), 17 deletions(-)

Comments

Laurent Pinchart Feb. 1, 2019, 10:34 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Fri, Feb 01, 2019 at 04:42:45PM +0100, Jacopo Mondi wrote:
> Rename the number of valid plane formats to 'planesCount' and the actual
> per-plane size information array to 'planes'.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

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

> ---
>  src/libcamera/include/v4l2_device.h |  4 ++--
>  src/libcamera/v4l2_device.cpp       | 29 ++++++++++++++---------------
>  2 files changed, 16 insertions(+), 17 deletions(-)
> 
> diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h
> index e65a540..4ff48fb 100644
> --- a/src/libcamera/include/v4l2_device.h
> +++ b/src/libcamera/include/v4l2_device.h
> @@ -63,8 +63,8 @@ public:
>  	struct {
>  		uint32_t size;
>  		uint32_t bpl;
> -	} planesFmt[3];
> -	unsigned int planes;
> +	} planes[3];
> +	unsigned int planesCount;
>  };
>  
>  class MediaEntity;
> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
> index 8cf566c..0d4d60f 100644
> --- a/src/libcamera/v4l2_device.cpp
> +++ b/src/libcamera/v4l2_device.cpp
> @@ -92,7 +92,7 @@ LOG_DEFINE_CATEGORY(V4L2)
>   *
>   * Formats defined as 'single planar' by the V4L2 APIs are represented with
>   * V4L2DeviceFormat instances with a single plane
> - * (V4L2DeviceFormat::planes = 1). Semi-planar and multiplanar formats use
> + * (V4L2DeviceFormat::planesCount = 1). Semi-planar and multiplanar formats use
>   * 2 and 3 planes respectively.
>   *
>   * V4L2DeviceFormat defines the exchange format between components that
> @@ -120,19 +120,18 @@ LOG_DEFINE_CATEGORY(V4L2)
>   */
>  
>  /**
> - * \var V4L2DeviceFormat::planesFmt
> + * \var V4L2DeviceFormat::planes
>   * \brief The per-plane size information
>   *
>   * Images are stored in memory in one or more data planes. Each data plane
>   * has a specific size and line length, which could differ from the image
>   * visible sizes to accommodate line or plane padding data.
>   *
> - * Only the first V4L2DeviceFormat::planes entries are considered valid.
> - *
> + * Only the first \ref planesCount entries are considered valid.
>   */
>  
>  /**
> - * \var V4L2DeviceFormat::planes
> + * \var V4L2DeviceFormat::planesCount
>   * \brief The number of valid data planes
>   */
>  
> @@ -315,9 +314,9 @@ int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)
>  	format->width = pix->width;
>  	format->height = pix->height;
>  	format->fourcc = pix->pixelformat;
> -	format->planes = 1;
> -	format->planesFmt[0].bpl = pix->bytesperline;
> -	format->planesFmt[0].size = pix->sizeimage;
> +	format->planesCount = 1;
> +	format->planes[0].bpl = pix->bytesperline;
> +	format->planes[0].size = pix->sizeimage;
>  
>  	return 0;
>  }
> @@ -360,11 +359,11 @@ int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)
>  	format->width = pix->width;
>  	format->height = pix->height;
>  	format->fourcc = pix->pixelformat;
> -	format->planes = pix->num_planes;
> +	format->planesCount = pix->num_planes;
>  
> -	for (unsigned int i = 0; i < format->planes; ++i) {
> -		format->planesFmt[i].bpl = pix->plane_fmt[i].bytesperline;
> -		format->planesFmt[i].size = pix->plane_fmt[i].sizeimage;
> +	for (unsigned int i = 0; i < format->planesCount; ++i) {
> +		format->planes[i].bpl = pix->plane_fmt[i].bytesperline;
> +		format->planes[i].size = pix->plane_fmt[i].sizeimage;
>  	}
>  
>  	return 0;
> @@ -380,11 +379,11 @@ int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)
>  	pix->width = format->width;
>  	pix->height = format->height;
>  	pix->pixelformat = format->fourcc;
> -	pix->num_planes = format->planes;
> +	pix->num_planes = format->planesCount;
>  
>  	for (unsigned int i = 0; i < pix->num_planes; ++i) {
> -		pix->plane_fmt[i].bytesperline = format->planesFmt[i].bpl;
> -		pix->plane_fmt[i].sizeimage = format->planesFmt[i].size;
> +		pix->plane_fmt[i].bytesperline = format->planes[i].bpl;
> +		pix->plane_fmt[i].sizeimage = format->planes[i].size;
>  	}
>  
>  	ret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format);

Patch

diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h
index e65a540..4ff48fb 100644
--- a/src/libcamera/include/v4l2_device.h
+++ b/src/libcamera/include/v4l2_device.h
@@ -63,8 +63,8 @@  public:
 	struct {
 		uint32_t size;
 		uint32_t bpl;
-	} planesFmt[3];
-	unsigned int planes;
+	} planes[3];
+	unsigned int planesCount;
 };
 
 class MediaEntity;
diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index 8cf566c..0d4d60f 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -92,7 +92,7 @@  LOG_DEFINE_CATEGORY(V4L2)
  *
  * Formats defined as 'single planar' by the V4L2 APIs are represented with
  * V4L2DeviceFormat instances with a single plane
- * (V4L2DeviceFormat::planes = 1). Semi-planar and multiplanar formats use
+ * (V4L2DeviceFormat::planesCount = 1). Semi-planar and multiplanar formats use
  * 2 and 3 planes respectively.
  *
  * V4L2DeviceFormat defines the exchange format between components that
@@ -120,19 +120,18 @@  LOG_DEFINE_CATEGORY(V4L2)
  */
 
 /**
- * \var V4L2DeviceFormat::planesFmt
+ * \var V4L2DeviceFormat::planes
  * \brief The per-plane size information
  *
  * Images are stored in memory in one or more data planes. Each data plane
  * has a specific size and line length, which could differ from the image
  * visible sizes to accommodate line or plane padding data.
  *
- * Only the first V4L2DeviceFormat::planes entries are considered valid.
- *
+ * Only the first \ref planesCount entries are considered valid.
  */
 
 /**
- * \var V4L2DeviceFormat::planes
+ * \var V4L2DeviceFormat::planesCount
  * \brief The number of valid data planes
  */
 
@@ -315,9 +314,9 @@  int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)
 	format->width = pix->width;
 	format->height = pix->height;
 	format->fourcc = pix->pixelformat;
-	format->planes = 1;
-	format->planesFmt[0].bpl = pix->bytesperline;
-	format->planesFmt[0].size = pix->sizeimage;
+	format->planesCount = 1;
+	format->planes[0].bpl = pix->bytesperline;
+	format->planes[0].size = pix->sizeimage;
 
 	return 0;
 }
@@ -360,11 +359,11 @@  int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)
 	format->width = pix->width;
 	format->height = pix->height;
 	format->fourcc = pix->pixelformat;
-	format->planes = pix->num_planes;
+	format->planesCount = pix->num_planes;
 
-	for (unsigned int i = 0; i < format->planes; ++i) {
-		format->planesFmt[i].bpl = pix->plane_fmt[i].bytesperline;
-		format->planesFmt[i].size = pix->plane_fmt[i].sizeimage;
+	for (unsigned int i = 0; i < format->planesCount; ++i) {
+		format->planes[i].bpl = pix->plane_fmt[i].bytesperline;
+		format->planes[i].size = pix->plane_fmt[i].sizeimage;
 	}
 
 	return 0;
@@ -380,11 +379,11 @@  int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)
 	pix->width = format->width;
 	pix->height = format->height;
 	pix->pixelformat = format->fourcc;
-	pix->num_planes = format->planes;
+	pix->num_planes = format->planesCount;
 
 	for (unsigned int i = 0; i < pix->num_planes; ++i) {
-		pix->plane_fmt[i].bytesperline = format->planesFmt[i].bpl;
-		pix->plane_fmt[i].sizeimage = format->planesFmt[i].size;
+		pix->plane_fmt[i].bytesperline = format->planes[i].bpl;
+		pix->plane_fmt[i].sizeimage = format->planes[i].size;
 	}
 
 	ret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format);