Report the correct desktop video mode on the iMX6
authorSam Lantinga <slouken@libsdl.org>
Wed, 10 Sep 2014 08:59:19 -0700
changeset 91283476d867bf43
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
     1.1 --- a/src/video/mx6/SDL_mx6opengles.c	Wed Sep 10 08:54:01 2014 -0700
     1.2 +++ b/src/video/mx6/SDL_mx6opengles.c	Wed Sep 10 08:59:19 2014 -0700
     1.3 @@ -150,8 +150,6 @@
     1.4      LOAD_VIV_FUNC(fbDestroyPixmap);
     1.5     
     1.6      displaydata = SDL_GetDisplayDriverData(0);
     1.7 -    displaydata->native_display = egl_viv_data->fbGetDisplayByIndex(0);
     1.8 -    egl_viv_data->fbGetDisplayGeometry(displaydata->native_display, &displaydata->width, &displaydata->height);
     1.9  
    1.10      _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(displaydata->native_display);
    1.11      if (!_this->egl_data->egl_display) {
     2.1 --- a/src/video/mx6/SDL_mx6video.c	Wed Sep 10 08:54:01 2014 -0700
     2.2 +++ b/src/video/mx6/SDL_mx6video.c	Wed Sep 10 08:59:19 2014 -0700
     2.3 @@ -124,6 +124,36 @@
     2.4      MX6_Create
     2.5  };
     2.6  
     2.7 +static void
     2.8 +MX6_UpdateDisplay(_THIS)
     2.9 +{
    2.10 +    SDL_VideoDisplay *display = &_this->displays[0];
    2.11 +    SDL_DisplayData *data = (SDL_DisplayData*)display->driverdata;
    2.12 +    EGLNativeDisplayType native_display = egl_viv_data->fbGetDisplayByIndex(0);
    2.13 +    SDL_DisplayMode current_mode;
    2.14 +    int pitch, bpp;
    2.15 +    unsigned long pixels;
    2.16 +
    2.17 +    /* Store the native EGL display */
    2.18 +    data->native_display = native_display;
    2.19 +
    2.20 +    SDL_zero(current_mode);
    2.21 +    egl_viv_data->fbGetDisplayInfo(native_display, &current_mode.w, &current_mode.h, &pixels, &pitch, &bpp);
    2.22 +    /* FIXME: How do we query refresh rate? */
    2.23 +    current_mode.refresh_rate = 60;
    2.24 +
    2.25 +    switch (bpp)
    2.26 +    {
    2.27 +    default: /* Is another format used? */
    2.28 +    case 16:
    2.29 +        current_mode.format = SDL_PIXELFORMAT_RGB565;
    2.30 +        break;
    2.31 +    }
    2.32 +
    2.33 +    display->desktop_mode = current_mode;
    2.34 +    display->current_mode = current_mode;
    2.35 +}
    2.36 +
    2.37  /*****************************************************************************/
    2.38  /* SDL Video and Display initialization/handling functions                   */
    2.39  /*****************************************************************************/
    2.40 @@ -138,16 +168,9 @@
    2.41      if (data == NULL) {
    2.42          return SDL_OutOfMemory();
    2.43      }
    2.44 -    
    2.45 -    /* Actual data will be set in SDL_GL_LoadLibrary call below */
    2.46 -    SDL_zero(current_mode);
    2.47 -    current_mode.w = 0;
    2.48 -    current_mode.h = 0;
    2.49 -    current_mode.refresh_rate = 60;
    2.50 -    current_mode.format = SDL_PIXELFORMAT_RGB565;
    2.51 -    current_mode.driverdata = NULL;
    2.52  
    2.53      SDL_zero(display);
    2.54 +    SDL_zero(current_mode);
    2.55      display.desktop_mode = current_mode;
    2.56      display.current_mode = current_mode;
    2.57      display.driverdata = data;
    2.58 @@ -156,6 +179,7 @@
    2.59      if (SDL_GL_LoadLibrary(NULL) < 0) {
    2.60          return -1;
    2.61      }
    2.62 +    MX6_UpdateDisplay(_this);
    2.63  
    2.64  #ifdef SDL_INPUT_LINUXEV    
    2.65      SDL_EVDEV_Init();
     3.1 --- a/src/video/mx6/SDL_mx6video.h	Wed Sep 10 08:54:01 2014 -0700
     3.2 +++ b/src/video/mx6/SDL_mx6video.h	Wed Sep 10 08:59:19 2014 -0700
     3.3 @@ -35,8 +35,6 @@
     3.4  {
     3.5      EGLNativeDisplayType native_display;
     3.6      EGLDisplay egl_display;
     3.7 -    int width;
     3.8 -    int height;
     3.9  } SDL_DisplayData;
    3.10  
    3.11  typedef struct SDL_WindowData