mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-22 17:51:16 +00:00
vadisplay: add gst_va_display_check_version()
This function compares the driver version with the user provided one to check if driver's is equal or bigger. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5800>
This commit is contained in:
parent
97e748466e
commit
8574bb8914
3 changed files with 99 additions and 0 deletions
|
@ -457,6 +457,27 @@ VADisplay.</doc>
|
|||
</instance-parameter>
|
||||
</parameters>
|
||||
</virtual-method>
|
||||
<method name="check_version" c:identifier="gst_va_display_check_version" version="1.24">
|
||||
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvadisplay.h"/>
|
||||
<return-value transfer-ownership="none">
|
||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvadisplay.c">whether driver version is equal or greater than @major.@minor</doc>
|
||||
<type name="gboolean" c:type="gboolean"/>
|
||||
</return-value>
|
||||
<parameters>
|
||||
<instance-parameter name="self" transfer-ownership="none">
|
||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvadisplay.c">a #GstVaDisplay</doc>
|
||||
<type name="VaDisplay" c:type="GstVaDisplay*"/>
|
||||
</instance-parameter>
|
||||
<parameter name="major" transfer-ownership="none">
|
||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvadisplay.c">major version to check</doc>
|
||||
<type name="guint" c:type="guint"/>
|
||||
</parameter>
|
||||
<parameter name="minor" transfer-ownership="none">
|
||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvadisplay.c">minor version to check</doc>
|
||||
<type name="guint" c:type="guint"/>
|
||||
</parameter>
|
||||
</parameters>
|
||||
</method>
|
||||
<method name="get_implementation" c:identifier="gst_va_display_get_implementation" version="1.20">
|
||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvadisplay.c">Get the the #GstVaImplementation type of @self.</doc>
|
||||
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/va/gstvadisplay.h"/>
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
#include "gstvadisplay.h"
|
||||
|
||||
#include <stdio.h> /* sscanf */
|
||||
#include <va/va.h>
|
||||
|
||||
GST_DEBUG_CATEGORY (gst_va_display_debug);
|
||||
|
@ -57,6 +58,9 @@ struct _GstVaDisplayPrivate
|
|||
gboolean init;
|
||||
GstVaImplementation impl;
|
||||
gchar *vendor_desc;
|
||||
|
||||
guint driver_major;
|
||||
guint driver_minor;
|
||||
};
|
||||
|
||||
#define gst_va_display_parent_class parent_class
|
||||
|
@ -122,6 +126,40 @@ _get_desc (const char *vendor, GstVaImplementation impl)
|
|||
return g_strdup (desc);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_get_driver_version (const char *vendor, GstVaImplementation impl,
|
||||
guint * major, guint * minor)
|
||||
{
|
||||
guint maj, min;
|
||||
|
||||
if (!vendor)
|
||||
return FALSE;
|
||||
|
||||
switch (impl) {
|
||||
case GST_VA_IMPLEMENTATION_MESA_GALLIUM:
|
||||
if (sscanf (vendor, "Mesa Gallium driver %d.%d.", &maj, &min) == 2) {
|
||||
*major = maj;
|
||||
*minor = min;
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
case GST_VA_IMPLEMENTATION_INTEL_IHD:
|
||||
case GST_VA_IMPLEMENTATION_INTEL_I965:{
|
||||
char *end = strstr (vendor, " - ");
|
||||
if (end && sscanf (end, " - %d.%d.", &maj, &min) == 2) {
|
||||
*major = maj;
|
||||
*minor = min;
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_gst_va_display_filter_driver (GstVaDisplay * self, gpointer foreign_display)
|
||||
{
|
||||
|
@ -129,6 +167,7 @@ _gst_va_display_filter_driver (GstVaDisplay * self, gpointer foreign_display)
|
|||
VADisplay dpy;
|
||||
const char *vendor;
|
||||
GstVaImplementation impl;
|
||||
guint major, minor;
|
||||
|
||||
g_assert ((foreign_display != NULL) ^ (priv->display != NULL));
|
||||
dpy = foreign_display ? foreign_display : priv->display;
|
||||
|
@ -150,6 +189,10 @@ _gst_va_display_filter_driver (GstVaDisplay * self, gpointer foreign_display)
|
|||
}
|
||||
priv->impl = impl;
|
||||
priv->vendor_desc = _get_desc (vendor, priv->impl);
|
||||
if (_get_driver_version (vendor, priv->impl, &major, &minor)) {
|
||||
priv->driver_major = major;
|
||||
priv->driver_minor = minor;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -411,3 +454,34 @@ gst_va_display_get_implementation (GstVaDisplay * self)
|
|||
priv = GET_PRIV (self);
|
||||
return priv->impl;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_va_display_check_version:
|
||||
* @self: a #GstVaDisplay
|
||||
* @major: major version to check
|
||||
* @minor: minor version to check
|
||||
*
|
||||
* Returns: whether driver version is equal or greater than @major.@minor
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
gboolean
|
||||
gst_va_display_check_version (GstVaDisplay * self, guint major, guint minor)
|
||||
{
|
||||
GstVaDisplayPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (GST_IS_VA_DISPLAY (self), FALSE);
|
||||
|
||||
priv = GET_PRIV (self);
|
||||
|
||||
/* if cannot parse the version, all it's valid */
|
||||
if (priv->driver_major == 0 && priv->driver_minor == 0)
|
||||
return TRUE;
|
||||
|
||||
if (priv->driver_major < major)
|
||||
return FALSE;
|
||||
if (priv->driver_minor < minor)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -127,6 +127,10 @@ GST_VA_API
|
|||
gpointer gst_va_display_get_va_dpy (GstVaDisplay * self);
|
||||
GST_VA_API
|
||||
GstVaImplementation gst_va_display_get_implementation (GstVaDisplay * self);
|
||||
GST_VA_API
|
||||
gboolean gst_va_display_check_version (GstVaDisplay * self,
|
||||
guint major,
|
||||
guint minor);
|
||||
|
||||
/**
|
||||
* gst_va_display_is_implementation:
|
||||
|
|
Loading…
Reference in a new issue