Skip to content

Commit

Permalink
Honor fullscreen_x/fullscreen_y in KMS/EGL.
Browse files Browse the repository at this point in the history
Try to find optimal mode.
  • Loading branch information
Themaister committed Apr 6, 2014
1 parent 36575fe commit 72c3177
Showing 1 changed file with 44 additions and 10 deletions.
54 changes: 44 additions & 10 deletions gfx/context/drm_egl_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,18 +388,14 @@ static bool gfx_ctx_init(void *data)

g_connector_id = g_connector->connector_id;

g_fb_width = g_drm_mode->hdisplay;
g_fb_height = g_drm_mode->vdisplay;

g_gbm_dev = gbm_create_device(g_drm_fd);
g_gbm_surface = gbm_surface_create(g_gbm_dev,
g_fb_width, g_fb_height,
GBM_FORMAT_XRGB8888,
GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
// First mode is assumed to be the "optimal" one for get_video_size() purposes.
g_fb_width = g_connector->modes[0].hdisplay;
g_fb_height = g_connector->modes[0].vdisplay;

if (!g_gbm_surface)
g_gbm_dev = gbm_create_device(g_drm_fd);
if (!g_gbm_dev)
{
RARCH_WARN("[KMS/EGL]: Couldn't create GBM surface.\n");
RARCH_WARN("[KMS/EGL]: Couldn't create GBM device.\n");
goto nextgpu;
}

Expand Down Expand Up @@ -457,6 +453,7 @@ static bool gfx_ctx_set_video_mode(void *data,
if (g_inited)
return false;

int i;
int ret = 0;
struct drm_fb *fb = NULL;

Expand Down Expand Up @@ -528,6 +525,43 @@ static bool gfx_ctx_set_video_mode(void *data,
attrib_ptr = NULL;
}

// Find desired video mode, and use that.
if (width == 0 && height == 0)
g_drm_mode = &g_connector->modes[0];
else
{
// Find first match.
for (i = 0; i < g_connector->count_modes; i++)
{
if (width == g_connector->modes[i].hdisplay && height == g_connector->modes[i].vdisplay)
{
g_drm_mode = &g_connector->modes[i];
break;
}
}
}

if (!g_drm_mode)
{
RARCH_ERR("[KMS/EGL]: Did not find suitable video mode for %u x %u.\n", width, height);
goto error;
}

g_fb_width = g_drm_mode->hdisplay;
g_fb_height = g_drm_mode->vdisplay;

// Create GBM surface.
g_gbm_surface = gbm_surface_create(g_gbm_dev,
g_fb_width, g_fb_height,
GBM_FORMAT_XRGB8888,
GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);

if (!g_gbm_surface)
{
RARCH_ERR("[KMS/EGL]: Couldn't create GBM surface.\n");
goto error;
}

g_egl_dpy = eglGetDisplay((EGLNativeDisplayType)g_gbm_dev);
if (!g_egl_dpy)
{
Expand Down

0 comments on commit 72c3177

Please sign in to comment.