[libcamera-devel,v2,5/8] libcamera: v4l2_device: Use non-interlaced frames

Message ID 20190213151027.6376-6-kieran.bingham@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: v4l2_device buffer sharing
Related show

Commit Message

Kieran Bingham Feb. 13, 2019, 3:10 p.m. UTC
Use V4L2_FIELD_NONE where applicable to disable support for interlaced frames.
We are unlikely to support interlaced frames on cameras so hardcode this field
type for now. If we decide to support interlacing later it can be revisited.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/libcamera/v4l2_device.cpp | 3 +++
 1 file changed, 3 insertions(+)

Comments

Laurent Pinchart Feb. 13, 2019, 3:46 p.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Wed, Feb 13, 2019 at 03:10:24PM +0000, Kieran Bingham wrote:
> Use V4L2_FIELD_NONE where applicable to disable support for interlaced frames.
> We are unlikely to support interlaced frames on cameras so hardcode this field
> type for now. If we decide to support interlacing later it can be revisited.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

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

> ---
>  src/libcamera/v4l2_device.cpp | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
> index 8c038239cf24..d690be9823f5 100644
> --- a/src/libcamera/v4l2_device.cpp
> +++ b/src/libcamera/v4l2_device.cpp
> @@ -423,6 +423,7 @@ int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)
>  	pix->height = format->height;
>  	pix->pixelformat = format->fourcc;
>  	pix->bytesperline = format->planes[0].bpl;
> +	pix->field = V4L2_FIELD_NONE;
>  
>  	ret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format);
>  	if (ret) {
> @@ -483,6 +484,7 @@ int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)
>  	pix->height = format->height;
>  	pix->pixelformat = format->fourcc;
>  	pix->num_planes = format->planesCount;
> +	pix->field = V4L2_FIELD_NONE;
>  
>  	for (unsigned int i = 0; i < pix->num_planes; ++i) {
>  		pix->plane_fmt[i].bytesperline = format->planes[i].bpl;
> @@ -681,6 +683,7 @@ int V4L2Device::queueBuffer(Buffer *buffer)
>  	buf.index = buffer->index();
>  	buf.type = bufferType_;
>  	buf.memory = memoryType_;
> +	buf.field = V4L2_FIELD_NONE;
>  
>  	if (V4L2_TYPE_IS_MULTIPLANAR(buf.type)) {
>  		buf.length = buffer->planes().size();
Niklas Söderlund Feb. 19, 2019, 11:53 a.m. UTC | #2
Hi Kieran,

Thanks for your patch.

On 2019-02-13 15:10:24 +0000, Kieran Bingham wrote:
> Use V4L2_FIELD_NONE where applicable to disable support for interlaced frames.
> We are unlikely to support interlaced frames on cameras so hardcode this field
> type for now. If we decide to support interlacing later it can be revisited.

I know this have been merged already and I agree with you that for now 
it's OK to hardcode do only use V4L2_FIELD_NONE. I do however think we 
would need to support interlaced formats in the future. Think embedded 
systems trying to do something with vision, there interlaced top/bottom 
fields can be useful to reduce latency to detect motion.

> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  src/libcamera/v4l2_device.cpp | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
> index 8c038239cf24..d690be9823f5 100644
> --- a/src/libcamera/v4l2_device.cpp
> +++ b/src/libcamera/v4l2_device.cpp
> @@ -423,6 +423,7 @@ int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)
>  	pix->height = format->height;
>  	pix->pixelformat = format->fourcc;
>  	pix->bytesperline = format->planes[0].bpl;
> +	pix->field = V4L2_FIELD_NONE;
>  
>  	ret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format);
>  	if (ret) {
> @@ -483,6 +484,7 @@ int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)
>  	pix->height = format->height;
>  	pix->pixelformat = format->fourcc;
>  	pix->num_planes = format->planesCount;
> +	pix->field = V4L2_FIELD_NONE;
>  
>  	for (unsigned int i = 0; i < pix->num_planes; ++i) {
>  		pix->plane_fmt[i].bytesperline = format->planes[i].bpl;
> @@ -681,6 +683,7 @@ int V4L2Device::queueBuffer(Buffer *buffer)
>  	buf.index = buffer->index();
>  	buf.type = bufferType_;
>  	buf.memory = memoryType_;
> +	buf.field = V4L2_FIELD_NONE;
>  
>  	if (V4L2_TYPE_IS_MULTIPLANAR(buf.type)) {
>  		buf.length = buffer->planes().size();
> -- 
> 2.19.1
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index 8c038239cf24..d690be9823f5 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -423,6 +423,7 @@  int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)
 	pix->height = format->height;
 	pix->pixelformat = format->fourcc;
 	pix->bytesperline = format->planes[0].bpl;
+	pix->field = V4L2_FIELD_NONE;
 
 	ret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format);
 	if (ret) {
@@ -483,6 +484,7 @@  int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)
 	pix->height = format->height;
 	pix->pixelformat = format->fourcc;
 	pix->num_planes = format->planesCount;
+	pix->field = V4L2_FIELD_NONE;
 
 	for (unsigned int i = 0; i < pix->num_planes; ++i) {
 		pix->plane_fmt[i].bytesperline = format->planes[i].bpl;
@@ -681,6 +683,7 @@  int V4L2Device::queueBuffer(Buffer *buffer)
 	buf.index = buffer->index();
 	buf.type = bufferType_;
 	buf.memory = memoryType_;
+	buf.field = V4L2_FIELD_NONE;
 
 	if (V4L2_TYPE_IS_MULTIPLANAR(buf.type)) {
 		buf.length = buffer->planes().size();