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 796985 - kmssink modesetting fails for multi-planar buffers
kmssink modesetting fails for multi-planar buffers
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: 1.15.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-08-17 09:37 UTC by Philipp Zabel
Modified: 2018-08-21 15:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
kmssink: configure mode setting from video info (2.27 KB, patch)
2018-08-17 09:37 UTC, Philipp Zabel
none Details | Review
kmssink: configure mode setting from video info (2.29 KB, patch)
2018-08-21 15:50 UTC, Nicolas Dufresne (ndufresne)
committed Details | Review

Description Philipp Zabel 2018-08-17 09:37:27 UTC
Created attachment 373369 [details] [review]
kmssink: configure mode setting from video info

drmModeGetFB returns -EINVAL for multi-planar framebuffers, causing configure_mode_setting to fail for multi-planar buffers such as I420 or NV12.
Only buffer width and height are needed to select a mode, and those can be determined from GstVideoInfo as well.
Comment 1 Víctor Manuel Jáquez Leal 2018-08-17 09:47:43 UTC
Review of attachment 373369 [details] [review]:

lgtm
Comment 2 Nicolas Dufresne (ndufresne) 2018-08-21 01:23:41 UTC
Review of attachment 373369 [details] [review]:

::: sys/kms/gstkmssink.c
@@ -441,3 @@
     goto connector_failed;
 
-  fb = drmModeGetFB (self->fd, fb_id);

On the plus side, we found that drmModeGetFB returns a handle that must be freed, and was currently leaked.
Comment 3 Nicolas Dufresne (ndufresne) 2018-08-21 01:23:47 UTC
Review of attachment 373369 [details] [review]:

::: sys/kms/gstkmssink.c
@@ -441,3 @@
     goto connector_failed;
 
-  fb = drmModeGetFB (self->fd, fb_id);

On the plus side, we found that drmModeGetFB returns a handle that must be freed, and was currently leaked.
Comment 4 Víctor Manuel Jáquez Leal 2018-08-21 09:16:49 UTC
(In reply to Nicolas Dufresne (ndufresne) from comment #3)
> Review of attachment 373369 [details] [review] [review]:
> 
> ::: sys/kms/gstkmssink.c
> @@ -441,3 @@
>      goto connector_failed;
>  
> -  fb = drmModeGetFB (self->fd, fb_id);
> 
> On the plus side, we found that drmModeGetFB returns a handle that must be
> freed, and was currently leaked.

It won't matter any more, but as far I see in the code, it was freed: 

https://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/sys/kms/gstkmssink.c#n468
Comment 5 Nicolas Dufresne (ndufresne) 2018-08-21 15:41:42 UTC
It's tricky, as it's creating a DUMB, and this need to also be freed using DRM_IOCTL_MODE_DESTROY_DUMB. But does not matter any-more. A bit like what we have in the KMS allocator. The refcounting is weirdly implemented on kernel side.
Comment 6 Nicolas Dufresne (ndufresne) 2018-08-21 15:42:08 UTC
Review of attachment 373369 [details] [review]:

::: sys/kms/gstkmssink.c
@@ +420,3 @@
   GstKMSMemory *kmsmem;
+  guint32 w;
+  guint32 h;

I'll drop these two, this is not really needed.
Comment 7 Devarsh Thakkar 2018-08-21 15:44:03 UTC
Review of attachment 373369 [details] [review]:

Thanks for the patch Philip.
Only suggestion I have is to directly use GST_VIDEO_INFO_HEIGHT and GST_VIDEO_INFO_WIDTH instead of using local declarations.
Please refer in-code comments for reference.

Regards,
-Devarsh

::: sys/kms/gstkmssink.c
@@ +420,3 @@
   GstKMSMemory *kmsmem;
+  guint32 w;
+  guint32 h;

In my opinion, above declarations can be avoided, please see my next comment.

@@ +445,2 @@
   for (i = 0; i < conn->count_modes; i++) {
+    if (conn->modes[i].vdisplay == h && conn->modes[i].hdisplay == w) {

I think we can avoid local integer declarations for width and height and directly use GST macros as shown below :

if (conn->modes[i].vdisplay == GST_VIDEO_INFO_HEIGHT (vinfo); && conn->modes[i].hdisplay == GST_VIDEO_INFO_WIDTH (vinfo);)
Comment 8 Devarsh Thakkar 2018-08-21 15:44:04 UTC
Review of attachment 373369 [details] [review]:

Thanks for the patch Philip.
Only suggestion I have is to directly use GST_VIDEO_INFO_HEIGHT and GST_VIDEO_INFO_WIDTH instead of using local declarations.
Please refer in-code comments for reference.

Regards,
-Devarsh

::: sys/kms/gstkmssink.c
@@ +420,3 @@
   GstKMSMemory *kmsmem;
+  guint32 w;
+  guint32 h;

In my opinion, above declarations can be avoided, please see my next comment.

@@ +445,2 @@
   for (i = 0; i < conn->count_modes; i++) {
+    if (conn->modes[i].vdisplay == h && conn->modes[i].hdisplay == w) {

I think we can avoid local integer declarations for width and height and directly use GST macros as shown below :

if (conn->modes[i].vdisplay == GST_VIDEO_INFO_HEIGHT (vinfo); && conn->modes[i].hdisplay == GST_VIDEO_INFO_WIDTH (vinfo);)
Comment 9 Devarsh Thakkar 2018-08-21 15:44:06 UTC
Review of attachment 373369 [details] [review]:

Thanks for the patch Philip.
Only suggestion I have is to directly use GST_VIDEO_INFO_HEIGHT and GST_VIDEO_INFO_WIDTH instead of using local declarations.
Please refer in-code comments for reference.

Regards,
-Devarsh

::: sys/kms/gstkmssink.c
@@ +420,3 @@
   GstKMSMemory *kmsmem;
+  guint32 w;
+  guint32 h;

In my opinion, above declarations can be avoided, please see my next comment.

@@ +445,2 @@
   for (i = 0; i < conn->count_modes; i++) {
+    if (conn->modes[i].vdisplay == h && conn->modes[i].hdisplay == w) {

I think we can avoid local integer declarations for width and height and directly use GST macros as shown below :

if (conn->modes[i].vdisplay == GST_VIDEO_INFO_HEIGHT (vinfo); && conn->modes[i].hdisplay == GST_VIDEO_INFO_WIDTH (vinfo);)
Comment 10 Nicolas Dufresne (ndufresne) 2018-08-21 15:50:22 UTC
Created attachment 373417 [details] [review]
kmssink: configure mode setting from video info

drmModeGetFB returns -EINVAL for multi-planar framebuffers. Instead of
depending on the framebuffer dimensions to select the mode, use width
and height from GstVideoInfo, which was used to create the framebuffer
in the first place.  This enables kmssink to display multi-planar
formats such as I420 or NV12 with modesetting enabled.
Comment 11 Nicolas Dufresne (ndufresne) 2018-08-21 15:51:16 UTC
Just updated accordingly.
Comment 12 Nicolas Dufresne (ndufresne) 2018-08-21 15:54:31 UTC
I've double check, gst_kms_allocator_bo_alloc() may modify stride/offset/size but not width and height, so this should have no side effect.
Comment 13 Nicolas Dufresne (ndufresne) 2018-08-21 15:54:52 UTC
Attachment 373417 [details] pushed as 62a194c - kmssink: configure mode setting from video info
Comment 14 Nicolas Dufresne (ndufresne) 2018-08-21 15:55:45 UTC
Shall we backport this to 1.14 ?