Report the correct desktop video mode on the iMX6
authorSam Lantinga <slouken@libsdl.org>
Wed, 10 Sep 2014 08:59:19 -0700
changeset 9128 3476d867bf43
parent 9127 a8c38ed1a674
child 9129 d183503df2e8
Report the correct desktop video mode on the iMX6
src/video/mx6/SDL_mx6opengles.c
src/video/mx6/SDL_mx6video.c
src/video/mx6/SDL_mx6video.h
--- a/src/video/mx6/SDL_mx6opengles.c	Wed Sep 10 08:54:01 2014 -0700
+++ b/src/video/mx6/SDL_mx6opengles.c	Wed Sep 10 08:59:19 2014 -0700
@@ -150,8 +150,6 @@
     LOAD_VIV_FUNC(fbDestroyPixmap);
    
     displaydata = SDL_GetDisplayDriverData(0);
-    displaydata->native_display = egl_viv_data->fbGetDisplayByIndex(0);
-    egl_viv_data->fbGetDisplayGeometry(displaydata->native_display, &displaydata->width, &displaydata->height);
 
     _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(displaydata->native_display);
     if (!_this->egl_data->egl_display) {
--- a/src/video/mx6/SDL_mx6video.c	Wed Sep 10 08:54:01 2014 -0700
+++ b/src/video/mx6/SDL_mx6video.c	Wed Sep 10 08:59:19 2014 -0700
@@ -124,6 +124,36 @@
     MX6_Create
 };
 
+static void
+MX6_UpdateDisplay(_THIS)
+{
+    SDL_VideoDisplay *display = &_this->displays[0];
+    SDL_DisplayData *data = (SDL_DisplayData*)display->driverdata;
+    EGLNativeDisplayType native_display = egl_viv_data->fbGetDisplayByIndex(0);
+    SDL_DisplayMode current_mode;
+    int pitch, bpp;
+    unsigned long pixels;
+
+    /* Store the native EGL display */
+    data->native_display = native_display;
+
+    SDL_zero(current_mode);
+    egl_viv_data->fbGetDisplayInfo(native_display, &current_mode.w, &current_mode.h, &pixels, &pitch, &bpp);
+    /* FIXME: How do we query refresh rate? */
+    current_mode.refresh_rate = 60;
+
+    switch (bpp)
+    {
+    default: /* Is another format used? */
+    case 16:
+        current_mode.format = SDL_PIXELFORMAT_RGB565;
+        break;
+    }
+
+    display->desktop_mode = current_mode;
+    display->current_mode = current_mode;
+}
+
 /*****************************************************************************/
 /* SDL Video and Display initialization/handling functions                   */
 /*****************************************************************************/
@@ -138,16 +168,9 @@
     if (data == NULL) {
         return SDL_OutOfMemory();
     }
-    
-    /* Actual data will be set in SDL_GL_LoadLibrary call below */
-    SDL_zero(current_mode);
-    current_mode.w = 0;
-    current_mode.h = 0;
-    current_mode.refresh_rate = 60;
-    current_mode.format = SDL_PIXELFORMAT_RGB565;
-    current_mode.driverdata = NULL;
 
     SDL_zero(display);
+    SDL_zero(current_mode);
     display.desktop_mode = current_mode;
     display.current_mode = current_mode;
     display.driverdata = data;
@@ -156,6 +179,7 @@
     if (SDL_GL_LoadLibrary(NULL) < 0) {
         return -1;
     }
+    MX6_UpdateDisplay(_this);
 
 #ifdef SDL_INPUT_LINUXEV    
     SDL_EVDEV_Init();
--- a/src/video/mx6/SDL_mx6video.h	Wed Sep 10 08:54:01 2014 -0700
+++ b/src/video/mx6/SDL_mx6video.h	Wed Sep 10 08:59:19 2014 -0700
@@ -35,8 +35,6 @@
 {
     EGLNativeDisplayType native_display;
     EGLDisplay egl_display;
-    int width;
-    int height;
 } SDL_DisplayData;
 
 typedef struct SDL_WindowData