SDL framebuffer device is hard coded to certain resolutions and color depth. If the frame buffer device resolution was not in the code, it may be failed to call "SDL_SetVideoMode" even though there is no problem in "SDL_Init" or "SDL_GetVideoMode" etc.

The following are needed to be done if you are using frame buffer device with special resolution:

1. Check your current frame buffer mode and parameters by "fbset". For example, the following are information from a 240x320x16bpp LCD (Yes, this is a vertical LCD!) get from "fbset":

# fbset
mode "240x320-68"
        # D: 6.434 MHz, H: 22.575 kHz, V: 67.998 Hz
geometry 240 320 240 320 16
timings 155424 21 11 5 5 13 2
vsync high
rgba 5/10,5/5,5/0,0/0
endmode

2. Find the code in SDL source file "/src/video/fbcon/SDL_fbvideo.c" and add the lines for this LCD. Note that these codes may have some differences for different version of SDL source package.

/* A list of video resolutions that we query for (sorted largest to smallest) */
static const SDL_Rect checkres[] = {
        {  0, 0, 1600, 1200 },          /* 16 bpp: 0x11E, or 286 */
        {  0, 0, 1408, 1056 },          /* 16 bpp: 0x19A, or 410 */
        {  0, 0, 1280, 1024 },          /* 16 bpp: 0x11A, or 282 */
        {  0, 0, 1152,  864 },          /* 16 bpp: 0x192, or 402 */
        {  0, 0, 1024,  768 },          /* 16 bpp: 0x117, or 279 */
        {  0, 0,  960,  720 },          /* 16 bpp: 0x18A, or 394 */
        {  0, 0,  800,  600 },          /* 16 bpp: 0x114, or 276 */
        {  0, 0,  768,  576 },          /* 16 bpp: 0x182, or 386 */
        {  0, 0,  720,  576 },          /* PAL */
        {  0, 0,  720,  480 },          /* NTSC */
        {  0, 0,  640,  480 },          /* 16 bpp: 0x111, or 273 */
        {  0, 0,  640,  400 },          /*  8 bpp: 0x100, or 256 */
        {  0, 0,  512,  384 },
        {  0, 0,  320,  240 },
        {  0, 0,  320,  200 },
        {  0, 0,  240,  320 }           /* OUR NEW LCD */
};

static const struct {
        int xres;
        int yres;
        int pixclock;
        int left;
        int right;
        int upper;
        int lower;
        int hslen;
        int vslen;
        int sync;
        int vmode;
} vesa_timings[] = {
#ifdef USE_VESA_TIMINGS /* Only tested on Matrox Millenium I */
        {  240,  320, 155424,  21, 11, 5,  5,  13, 2, 0, 0 },   /* OUR NEW LCD */
        {  640,  400, 39771,  48, 16, 39,  8,  96, 2, 2, 0 },   /* 70 Hz */
        {  640,  480, 39683,  48, 16, 33, 10,  96, 2, 0, 0 },   /* 60 Hz */
        {  768,  576, 26101, 144, 16, 28,  6, 112, 4, 0, 0 },   /* 60 Hz */
        {  800,  600, 24038, 144, 24, 28,  8, 112, 6, 0, 0 },   /* 60 Hz */
        {  960,  720, 17686, 144, 24, 28,  8, 112, 4, 0, 0 },   /* 60 Hz */
        { 1024,  768, 15386, 160, 32, 30,  4, 128, 4, 0, 0 },   /* 60 Hz */
        { 1152,  864, 12286, 192, 32, 30,  4, 128, 4, 0, 0 },   /* 60 Hz */
        { 1280, 1024,  9369, 224, 32, 32,  4, 136, 4, 0, 0 },   /* 60 Hz */
        { 1408, 1056,  8214, 256, 40, 32,  5, 144, 5, 0, 0 },   /* 60 Hz */
        { 1600, 1200,/*?*/0, 272, 48, 32,  5, 152, 5, 0, 0 },   /* 60 Hz */
#else
        /* You can generate these timings from your XF86Config file using
           the 'modeline2fb' perl script included with the fbset package.
           These timings were generated for Matrox Millenium I, 15" monitor.
        */
        // {  320,  200, 79440,  16, 16, 20,  4,  48, 1, 0, 2 },/* 70 Hz */
        // {  320,  240, 63492,  16, 16, 16,  4,  48, 2, 0, 2 },/* 72 Hz */
        {  240,  320, 155424, 21, 11,  5,  5,  13, 2, 0, 0 },   /* OUR NEW LCD */
        {  512,  384, 49603,  48, 16, 16,  1,  64, 3, 0, 0 },   /* 78 Hz */
        {  640,  400, 31746,  96, 32, 41,  1,  64, 3, 2, 0 },   /* 85 Hz */
        {  640,  480, 31746, 120, 16, 16,  1,  64, 3, 0, 0 },   /* 75 Hz */
        {  768,  576, 26101, 144, 16, 28,  6, 112, 4, 0, 0 },   /* 60 Hz */
        {  800,  600, 20000,  64, 56, 23, 37, 120, 6, 3, 0 },   /* 72 Hz */
        {  960,  720, 17686, 144, 24, 28,  8, 112, 4, 0, 0 },   /* 60 Hz */
        { 1024,  768, 13333, 144, 24, 29,  3, 136, 6, 0, 0 },   /* 70 Hz */
        { 1152,  864, 12286, 192, 32, 30,  4, 128, 4, 0, 0 },   /* 60 Hz */
        { 1280, 1024,  9369, 224, 32, 32,  4, 136, 4, 0, 0 },   /* 60 Hz */
        { 1408, 1056,  8214, 256, 40, 32,  5, 144, 5, 0, 0 },   /* 60 Hz */
        { 1600, 1200,/*?*/0, 272, 48, 32,  5, 152, 5, 0, 0 },   /* 60 Hz */
#endif
};

Three lines we added are:

        {  0, 0,  240,  320 }           /* OUR NEW LCD */
        {  240,  320, 155424,  21, 11, 5,  5,  13, 2, 0, 0 },   /* OUR NEW LCD */
        {  240,  320, 155424,  21, 11, 5,  5,  13, 2, 0, 0 },   /* OUR NEW LCD */

[FIXME] The use of "sync" and "vmode" parameters are uncertain, try to use 0 in both fields.

[FIXME] Due to limitation of screen size scanning algorithm implemented in SDL, we may need to comment out the screen size if its dimension (width or height) above are not consistantly increased / decreased. In our example, the width of LCD is 240 which is smaller than 320, while the height of LCD is 320 which is larger than 240.

FAQ_Linux_with_non-standard_framebuffer_device (last edited 2008-04-17 08:18:37 by localhost)