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.

https://bugzilla.gnome.org/show_bug.cgi?id=796985
This commit is contained in:
Philipp Zabel 2018-08-17 11:12:26 +02:00 committed by Nicolas Dufresne
parent 203d1825c5
commit 62a194c781

View file

@ -414,7 +414,6 @@ configure_mode_setting (GstKMSSink * self, GstVideoInfo * vinfo)
gboolean ret;
drmModeConnector *conn;
int err;
drmModeFB *fb;
gint i;
drmModeModeInfo *mode;
guint32 fb_id;
@ -422,7 +421,6 @@ configure_mode_setting (GstKMSSink * self, GstVideoInfo * vinfo)
ret = FALSE;
conn = NULL;
fb = NULL;
mode = NULL;
kmsmem = NULL;
@ -440,13 +438,9 @@ configure_mode_setting (GstKMSSink * self, GstVideoInfo * vinfo)
if (!conn)
goto connector_failed;
fb = drmModeGetFB (self->fd, fb_id);
if (!fb)
goto framebuffer_failed;
for (i = 0; i < conn->count_modes; i++) {
if (conn->modes[i].vdisplay == fb->height &&
conn->modes[i].hdisplay == fb->width) {
if (conn->modes[i].vdisplay == GST_VIDEO_INFO_HEIGHT (vinfo) &&
conn->modes[i].hdisplay == GST_VIDEO_INFO_WIDTH (vinfo)) {
mode = &conn->modes[i];
break;
}
@ -464,8 +458,6 @@ configure_mode_setting (GstKMSSink * self, GstVideoInfo * vinfo)
ret = TRUE;
bail:
if (fb)
drmModeFreeFB (fb);
if (conn)
drmModeFreeConnector (conn);
@ -483,12 +475,6 @@ connector_failed:
GST_ERROR_OBJECT (self, "Could not find a valid monitor connector");
goto bail;
}
framebuffer_failed:
{
GST_ERROR_OBJECT (self, "drmModeGetFB failed: %s (%d)",
strerror (errno), errno);
goto bail;
}
mode_failed:
{
GST_ERROR_OBJECT (self, "cannot find appropriate mode");