kmssink: set mode based on framebuffer configuration

Displays usually support multiple modes. Therefore, the kmssink should
not only support the preferred mode, but any mode that is supported by
the display.

https://bugzilla.gnome.org/show_bug.cgi?id=773473
This commit is contained in:
Michael Tretter 2016-11-08 15:26:40 +01:00 committed by Víctor Manuel Jáquez Leal
parent f52baadd1e
commit ca96cc6083

View file

@ -325,9 +325,14 @@ configure_mode_setting (GstKMSSink * self, guint32 fb_id)
gboolean ret;
drmModeConnector *conn;
int err;
drmModeFB *fb;
gint i;
drmModeModeInfo *mode;
ret = FALSE;
conn = NULL;
fb = NULL;
mode = NULL;
if (self->conn_id < 0)
goto bail;
@ -338,14 +343,30 @@ configure_mode_setting (GstKMSSink * self, guint32 fb_id)
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) {
mode = &conn->modes[i];
break;
}
}
if (!mode)
goto mode_failed;
err = drmModeSetCrtc (self->fd, self->crtc_id, fb_id, 0, 0,
(uint32_t *) & self->conn_id, 1, &conn->modes[0]);
(uint32_t *) & self->conn_id, 1, mode);
if (err)
goto modesetting_failed;
ret = TRUE;
bail:
if (fb)
drmModeFreeFB (fb);
if (conn)
drmModeFreeConnector (conn);
@ -357,6 +378,17 @@ 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");
goto bail;
}
modesetting_failed:
{
GST_ERROR_OBJECT (self, "Failed to set mode: %s", strerror (errno));