Commit ca96cc60 authored by Michael Tretter's avatar Michael Tretter Committed by Víctor Manuel Jáquez Leal

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
parent f52baadd
......@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment