[libcamera-devel] [PATCH] libcamera: v4l2_videodevice: provide hasMediaController()

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Oct 27 14:27:27 CEST 2021


Hi Kieran,

Thank you for the patch.

On Wed, Oct 27, 2021 at 01:07:13PM +0100, Kieran Bingham wrote:
> The V4L2Capability has helpers to interogate the capabilities
> of a device.
> 
> V4L2VideoDevice::enumPixelformats accesses the raw capabilites to check
> if the device is supported by a MediaController device.
> 
> Provide a helper, and update the usage.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> 
> ---
> This might also be used in the upcoming RPi MediaController series, but
> shouldn't block integration of that ...
> ---
>  include/libcamera/internal/v4l2_videodevice.h | 4 ++++
>  src/libcamera/v4l2_videodevice.cpp            | 2 +-
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h
> index efe34d47e72b..a1c458e45088 100644
> --- a/include/libcamera/internal/v4l2_videodevice.h
> +++ b/include/libcamera/internal/v4l2_videodevice.h
> @@ -109,6 +109,10 @@ struct V4L2Capability final : v4l2_capability {
>  	{
>  		return device_caps() & V4L2_CAP_STREAMING;
>  	}
> +	bool hasMediaController() const
> +	{
> +		return device_caps() & V4L2_CAP_IO_MC;
> +	}
>  };
>  
>  class V4L2BufferCache
> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
> index 0cc622f91f2d..0fbf32bcfc00 100644
> --- a/src/libcamera/v4l2_videodevice.cpp
> +++ b/src/libcamera/v4l2_videodevice.cpp
> @@ -1019,7 +1019,7 @@ std::vector<V4L2PixelFormat> V4L2VideoDevice::enumPixelformats(uint32_t code)
>  	std::vector<V4L2PixelFormat> formats;
>  	int ret;
>  
> -	if (code && !(caps_.device_caps() & V4L2_CAP_IO_MC)) {
> +	if (code && !(caps_.hasMediaController())) {

	if (code && !caps_.hasMediaController()) {

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

>  		LOG(V4L2, Error)
>  			<< "Media bus code filtering not supported by the device";
>  		return {};

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list