After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 797025 - kmssink: Add "restore-crtc" property
kmssink: Add "restore-crtc" property
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal enhancement
: 1.15.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-08-25 18:04 UTC by Devarsh Thakkar
Modified: 2018-08-30 12:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[patch] Add restore-crtc property for kmssink (4.76 KB, patch)
2018-08-25 18:04 UTC, Devarsh Thakkar
needs-work Details | Review
kmssink: Add "restore-crtc" property (4.74 KB, patch)
2018-08-29 18:18 UTC, Nicolas Dufresne (ndufresne)
committed Details | Review

Description Devarsh Thakkar 2018-08-25 18:04:18 UTC
Created attachment 373457 [details] [review]
[patch] Add restore-crtc property for kmssink

This adds "restore-crtc" property using which one
can restore previous crtc mode.

By default it is enabled, if CRTC was already
active with a valid mode and kmssink set a new mode
on CRTC using force-modesetting.

This helps user restore previous crtc mode and get
the previous session back after running a kmssink
pipeline involving a force-modesetting.

For e.g. When running a kmssink pipeline on rpi
using force-modesetting on tty console, it was giving
a blank screen after pipeline, and now with help of restore-crtc
functionality, CRTC is set with previous crtc mode
previously active on tty console.
Comment 1 Devarsh Thakkar 2018-08-25 18:06:57 UTC
Tested on raspberry pi.
Comment 2 Nicolas Dufresne (ndufresne) 2018-08-27 16:05:27 UTC
Review of attachment 373457 [details] [review]:

::: sys/kms/gstkmssink.c
@@ +682,3 @@
   if (pres)
     drmModeFreePlaneResources (pres);
+  if (crtc && !self->restore_crtc)

We should clear crtc pointer to NULL whenever we transfer ownership to self->saved_crtc instead of adding this condition.

@@ +793,3 @@
+          ("Failed to restore previous CRTC mode"), (NULL));
+    else
+      drmModeFreeCrtc ((drmModeCrtc *) self->saved_crtc);

First read, this seems to leak something on error. Can you comment on how the ownership of drmModeSetCrtc works in a way that code isn't leaking any DRM object ? You should set saved_crtc to NULL here.

@@ +794,3 @@
+    else
+      drmModeFreeCrtc ((drmModeCrtc *) self->saved_crtc);
+  }

If restore_crtc is FALSE, there is still a change, due to the API, that self->saved_crtc is set. You should free it, and then set that pointer to NULL.

@@ +1794,3 @@
+   * Restore previous crtc setting if new crtc mode was set forcefully.
+   * By default this is enabled if user set crtc with a new mode on an already active
+   * crtc wchich was having a valid mode.

Typo, wchich -> which

@@ +1799,3 @@
+  g_properties[PROP_RESTORE_CRTC] =
+      g_param_spec_boolean ("restore-crtc", "Restore CRTC mode",
+      "When enabled and crtc was set with a new mode, previous crtc mode will be restored on exit",

Capital CRTC please. Instead of on exit, can you document the transition ?
Comment 3 Nicolas Dufresne (ndufresne) 2018-08-29 18:18:42 UTC
Created attachment 373501 [details] [review]
kmssink: Add "restore-crtc" property

This adds "restore-crtc" property using which one
can restore previous crtc mode.

By default it is enabled, if CRTC was already
active with a valid mode and kmssink set a new mode
on CRTC using force-modesetting.

This helps user restore previous crtc mode and get
the previous session back after running a kmssink
pipeline involving a force-modesetting.

For e.g. When running a kmssink pipeline on rpi
using force-modesetting on tty console, it was giving
a blank screen after pipeline, and now with help of restore-crtc
functionality, CRTC is set with previous crtc mode
previously active on tty console.

Edited-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Comment 4 Nicolas Dufresne (ndufresne) 2018-08-29 18:20:06 UTC
Just applied my own review. This shouldn't be racy anymore, and is also simpler. I also fixes the wrong usage of GST_ELEMENT_ERROR() macro, it's pointless on shutdown as very often the message will be flushed.
Comment 5 Nicolas Dufresne (ndufresne) 2018-08-29 18:45:49 UTC
Attachment 373501 [details] pushed as 7d79378 - kmssink: Add "restore-crtc" property
Comment 6 Nicolas Dufresne (ndufresne) 2018-08-29 18:46:35 UTC
Oh, and tested on Intel DRM.
Comment 7 Devarsh Thakkar 2018-08-30 04:31:04 UTC
Thanks Nicholas for the review and edit, let me know if anything pending here, I can spend some time on weekend, if you want me to run some tests or confirm drm object freeing from kernel side.
Comment 8 Nicolas Dufresne (ndufresne) 2018-08-30 12:18:29 UTC
Hi Devarsh, there was indeed a leak of the saved_crtc, but in error path only, it's fixed now, it shouldn't be a problem any-more. Thanks for your work !

p.s. I've written a proposal here, https://bugzilla.gnome.org/show_bug.cgi?id=797047 . In your fullscreen-overlay initial work, there is also the aspect of forcing an that isn't yet covered, but I think I have some ideas that may not require a new property.