[libcamera-devel] [PATCH v5 4/9] libcamera: v4l2_device: Add support for META_CAPTURE devices

Laurent Pinchart laurent.pinchart at ideasonboard.com
Thu Feb 28 22:54:31 CET 2019


Hi Jacopo,

Thank you for the patch.

On Thu, Feb 28, 2019 at 09:01:46PM +0100, Jacopo Mondi wrote:
> Add support for devices that provide video meta-data to v4l2_device.cpp
> and re-arrange bufferType handling in open() method.
> 
> Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> ---
>  src/libcamera/include/v4l2_device.h |  4 +++
>  src/libcamera/v4l2_device.cpp       | 38 +++++++++++++++++------------
>  2 files changed, 27 insertions(+), 15 deletions(-)
> 
> diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h
> index 1d31d1b403bc..733bd69959f3 100644
> --- a/src/libcamera/include/v4l2_device.h
> +++ b/src/libcamera/include/v4l2_device.h
> @@ -53,6 +53,10 @@ struct V4L2Capability final : v4l2_capability {
>  		return device_caps() & (V4L2_CAP_VIDEO_CAPTURE |
>  					V4L2_CAP_VIDEO_CAPTURE_MPLANE);
>  	}
> +	bool isMetaCapture() const
> +	{
> +		return device_caps() & V4L2_CAP_META_CAPTURE;
> +	}
>  	bool isOutput() const

As explained in a previous review, I think you should reorganize these
functions.

>  	{
>  		return device_caps() & (V4L2_CAP_VIDEO_OUTPUT |
> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
> index 24e115554a99..9bfa10e8a151 100644
> --- a/src/libcamera/v4l2_device.cpp
> +++ b/src/libcamera/v4l2_device.cpp
> @@ -79,6 +79,15 @@ LOG_DEFINE_CATEGORY(V4L2)
>   * \return True if the device can output video frames
>   */
>  
> +/**
> + * \fn bool V4L2Capability::isMetaCapture()
> + * \brief Identify if the device is capable of providing video meta-data
> + *
> + * TODO: add support for META_OUTPUT, introduced in Linux v5.0

You can use \todo instead of TODO:.

With these,

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

> + *
> + * \return True if the device can capture video meta-data
> + */
> +
>  /**
>   * \fn bool V4L2Capability::hasStreaming()
>   * \brief Determine if the device can perform Streaming I/O
> @@ -280,33 +289,32 @@ int V4L2Device::open()
>  		<< "Opened device " << caps_.bus_info() << ": "
>  		<< caps_.driver() << ": " << caps_.card();
>  
> -	if (!caps_.isCapture() && !caps_.isOutput()) {
> -		LOG(V4L2, Debug) << "Device is not a supported type";
> -		return -EINVAL;
> -	}
> -
>  	if (!caps_.hasStreaming()) {
>  		LOG(V4L2, Error) << "Device does not support streaming I/O";
>  		return -EINVAL;
>  	}
>  
> -	if (caps_.isCapture())
> +	/*
> +	 * Set buffer type and wait for read notifications on CAPTURE devices
> +	 * (POLLIN), and write notifications for OUTPUT devices (POLLOUT).
> +	 */
> +	if (caps_.isCapture()) {
> +		fdEvent_ = new EventNotifier(fd_, EventNotifier::Read);
>  		bufferType_ = caps_.isMultiplanar()
>  			    ? V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
>  			    : V4L2_BUF_TYPE_VIDEO_CAPTURE;
> -	else
> +	} else if (caps_.isOutput()) {
> +		fdEvent_ = new EventNotifier(fd_, EventNotifier::Write);
>  		bufferType_ = caps_.isMultiplanar()
>  			    ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
>  			    : V4L2_BUF_TYPE_VIDEO_OUTPUT;
> -
> -	/*
> -	 *  We wait for Read notifications on CAPTURE devices (POLLIN), and
> -	 *  Write notifications for OUTPUT devices (POLLOUT).
> -	 */
> -	if (caps_.isCapture())
> +	} else if (caps_.isMetaCapture()) {
>  		fdEvent_ = new EventNotifier(fd_, EventNotifier::Read);
> -	else
> -		fdEvent_ = new EventNotifier(fd_, EventNotifier::Write);
> +		bufferType_ = V4L2_BUF_TYPE_META_CAPTURE;
> +	} else {
> +		LOG(V4L2, Debug) << "Device is not a supported type";
> +		return -EINVAL;
> +	}
>  
>  	fdEvent_->activated.connect(this, &V4L2Device::bufferAvailable);
>  	fdEvent_->setEnabled(false);

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list