[libcamera-devel,2/2] libcamera: v4l2_device: List controls when setting file descriptor
diff mbox series

Message ID 20221003190706.19816-3-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: v4l2_device: Fix control enumeration for M2M devices
Related show

Commit Message

Laurent Pinchart Oct. 3, 2022, 7:07 p.m. UTC
The base V4L2Device class is bound to a video device node by either
open(), which opens the device node and creates a new file descriptor,
or setFd(), which takes an already open file descriptor. The former
populates the V4L2Device instance controls, while the latter doesn't.
This prevents using controls on V4L2 M2M devices. Fix it by populating
controls in setFd(), which is called by open().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/v4l2_device.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Umang Jain Oct. 4, 2022, 6:54 a.m. UTC | #1
Hi Laurent,

Thank you for the patch.

On 10/4/22 12:37 AM, Laurent Pinchart via libcamera-devel wrote:
> The base V4L2Device class is bound to a video device node by either
> open(), which opens the device node and creates a new file descriptor,
> or setFd(), which takes an already open file descriptor. The former
> populates the V4L2Device instance controls, while the latter doesn't.
> This prevents using controls on V4L2 M2M devices. Fix it by populating
> controls in setFd(), which is called by open().
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>   src/libcamera/v4l2_device.cpp | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
> index d7ebf63811b4..c4d40d7d0842 100644
> --- a/src/libcamera/v4l2_device.cpp
> +++ b/src/libcamera/v4l2_device.cpp
> @@ -97,8 +97,6 @@ int V4L2Device::open(unsigned int flags)
>   
>   	setFd(std::move(fd));
>   
> -	listControls();
> -
>   	return 0;
>   }
>   
> @@ -129,6 +127,8 @@ int V4L2Device::setFd(UniqueFD fd)
>   	fdEventNotifier_->activated.connect(this, &V4L2Device::eventAvailable);
>   	fdEventNotifier_->setEnabled(false);
>   
> +	listControls();
> +
>   	return 0;
>   }
>
Xavier Roumegue Oct. 4, 2022, 11:50 a.m. UTC | #2
Hi Laurent,

Thanks for your patch !

On 10/3/22 21:07, Laurent Pinchart wrote:
> The base V4L2Device class is bound to a video device node by either
> open(), which opens the device node and creates a new file descriptor,
> or setFd(), which takes an already open file descriptor. The former
> populates the V4L2Device instance controls, while the latter doesn't.
> This prevents using controls on V4L2 M2M devices. Fix it by populating
> controls in setFd(), which is called by open().
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>   src/libcamera/v4l2_device.cpp | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
> index d7ebf63811b4..c4d40d7d0842 100644
> --- a/src/libcamera/v4l2_device.cpp
> +++ b/src/libcamera/v4l2_device.cpp
> @@ -97,8 +97,6 @@ int V4L2Device::open(unsigned int flags)
>   
>   	setFd(std::move(fd));
>   
> -	listControls();
> -
>   	return 0;
>   }
>   
> @@ -129,6 +127,8 @@ int V4L2Device::setFd(UniqueFD fd)
>   	fdEventNotifier_->activated.connect(this, &V4L2Device::eventAvailable);
>   	fdEventNotifier_->setEnabled(false);
>   
> +	listControls();
> +
>   	return 0;
>   }
>   

Reviewed-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>

Patch
diff mbox series

diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index d7ebf63811b4..c4d40d7d0842 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -97,8 +97,6 @@  int V4L2Device::open(unsigned int flags)
 
 	setFd(std::move(fd));
 
-	listControls();
-
 	return 0;
 }
 
@@ -129,6 +127,8 @@  int V4L2Device::setFd(UniqueFD fd)
 	fdEventNotifier_->activated.connect(this, &V4L2Device::eventAvailable);
 	fdEventNotifier_->setEnabled(false);
 
+	listControls();
+
 	return 0;
 }