From daecbd1ff0857255232e0dc3c6974cf0b2ab5de2 Mon Sep 17 00:00:00 2001 From: Bill Hofmann Date: Mon, 21 Nov 2022 15:48:49 -0500 Subject: [PATCH] kmssink: Add skip-vsync property The legacy emulation in DRM/KMS drivers badly interact with GStreamer and may cause the framerate to be halved. With this property, users can disable vsync (which is handled internally by the emulation) in order to regain the full framerate. Part-of: --- .../docs/plugins/gst_plugins_cache.json | 12 ++++++++++ .../gst-plugins-bad/sys/kms/gstkmssink.c | 24 ++++++++++++++++++- .../gst-plugins-bad/sys/kms/gstkmssink.h | 1 + 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json b/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json index 778557af47..92604f1a41 100644 --- a/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json +++ b/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json @@ -31312,6 +31312,18 @@ "readable": true, "type": "gboolean", "writable": true + }, + "skip-vsync": { + "blurb": "When enabled will not wait internally for vsync. Should be used for atomic drivers to avoid double vsync.", + "conditionally-available": false, + "construct": true, + "construct-only": false, + "controllable": false, + "default": "false", + "mutable": "null", + "readable": true, + "type": "gboolean", + "writable": true } }, "rank": "secondary" diff --git a/subprojects/gst-plugins-bad/sys/kms/gstkmssink.c b/subprojects/gst-plugins-bad/sys/kms/gstkmssink.c index cba6a36ec8..e929d28502 100644 --- a/subprojects/gst-plugins-bad/sys/kms/gstkmssink.c +++ b/subprojects/gst-plugins-bad/sys/kms/gstkmssink.c @@ -98,6 +98,7 @@ enum PROP_CONNECTOR_PROPS, PROP_PLANE_PROPS, PROP_FD, + PROP_SKIP_VSYNC, PROP_N, }; @@ -1683,7 +1684,7 @@ retry_set_plane: sync_frame: /* Wait for the previous frame to complete redraw */ - if (!gst_kms_sink_sync (self)) { + if (!self->skip_vsync && !gst_kms_sink_sync (self)) { GST_OBJECT_UNLOCK (self); goto bail; } @@ -1884,6 +1885,9 @@ gst_kms_sink_set_property (GObject * object, guint prop_id, case PROP_FD: _validate_and_set_external_fd (sink, g_value_get_int (value)); break; + case PROP_SKIP_VSYNC: + sink->skip_vsync = g_value_get_boolean (value); + break; default: if (!gst_video_overlay_set_property (object, PROP_N, prop_id, value)) G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -1940,6 +1944,9 @@ gst_kms_sink_get_property (GObject * object, guint prop_id, case PROP_FD: g_value_set_int (value, sink->fd); break; + case PROP_SKIP_VSYNC: + g_value_set_boolean (value, sink->skip_vsync); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1973,6 +1980,7 @@ gst_kms_sink_init (GstKMSSink * sink) gst_poll_fd_init (&sink->pollfd); sink->poll = gst_poll_new (TRUE); gst_video_info_init (&sink->vinfo); + sink->skip_vsync = FALSE; } static void @@ -2152,6 +2160,20 @@ gst_kms_sink_class_init (GstKMSSinkClass * klass) "DRM file descriptor", -1, G_MAXINT, -1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT); + /** + * kmssink:skip-vsync: + * + * For some cases, to suppress internal vsync, which can drop framerate + * in half, set this to 1. + * + * Since: 1.22 + */ + g_properties[PROP_SKIP_VSYNC] = + g_param_spec_boolean ("skip-vsync", "Skip Internal VSync", + "When enabled will not wait internally for vsync. " + "Should be used for atomic drivers to avoid double vsync.", FALSE, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT); + g_object_class_install_properties (gobject_class, PROP_N, g_properties); gst_video_overlay_install_properties (gobject_class, PROP_N); diff --git a/subprojects/gst-plugins-bad/sys/kms/gstkmssink.h b/subprojects/gst-plugins-bad/sys/kms/gstkmssink.h index 536b0a7230..e20e2c3654 100644 --- a/subprojects/gst-plugins-bad/sys/kms/gstkmssink.h +++ b/subprojects/gst-plugins-bad/sys/kms/gstkmssink.h @@ -95,6 +95,7 @@ struct _GstKMSSink { gboolean reconfigure; gboolean is_internal_fd; + gboolean skip_vsync; }; struct _GstKMSSinkClass {