From 3b42c1878d809b17e45e9b8bfb58a10c80c88d7a Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Wed, 3 Mar 2021 15:38:45 -0300 Subject: [PATCH] v4l2codecs: vp8: Check kernel version Print a warning if the kernel version is too old. Signed-off-by: Ezequiel Garcia Part-of: --- sys/v4l2codecs/gstv4l2codecvp8dec.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sys/v4l2codecs/gstv4l2codecvp8dec.c b/sys/v4l2codecs/gstv4l2codecvp8dec.c index c68391ef2e..557b317594 100644 --- a/sys/v4l2codecs/gstv4l2codecvp8dec.c +++ b/sys/v4l2codecs/gstv4l2codecvp8dec.c @@ -26,6 +26,12 @@ #include "gstv4l2codecpool.h" #include "gstv4l2codecvp8dec.h" +#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) + +#define V4L2_MIN_KERNEL_VER_MAJOR 5 +#define V4L2_MIN_KERNEL_VER_MINOR 13 +#define V4L2_MIN_KERNEL_VERSION KERNEL_VERSION(V4L2_MIN_KERNEL_VER_MAJOR, V4L2_MIN_KERNEL_VER_MINOR, 0) + GST_DEBUG_CATEGORY_STATIC (v4l2_vp8dec_debug); #define GST_CAT_DEFAULT v4l2_vp8dec_debug @@ -103,6 +109,7 @@ static gboolean gst_v4l2_codec_vp8_dec_open (GstVideoDecoder * decoder) { GstV4l2CodecVp8Dec *self = GST_V4L2_CODEC_VP8_DEC (decoder); + guint version; if (!gst_v4l2_decoder_open (self->decoder)) { GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ_WRITE, @@ -111,6 +118,13 @@ gst_v4l2_codec_vp8_dec_open (GstVideoDecoder * decoder) return FALSE; } + version = gst_v4l2_decoder_get_version (self->decoder); + if (version < V4L2_MIN_KERNEL_VERSION) + GST_WARNING_OBJECT (self, + "V4L2 API v%u.%u too old, at least v%u.%u required", + (version >> 16) & 0xff, (version >> 8) & 0xff, + V4L2_MIN_KERNEL_VER_MAJOR, V4L2_MIN_KERNEL_VER_MINOR); + return TRUE; }