Modules/VESA - Deferred mode population until needed (reduces lag at boot)
authorJohn Hodge <[email protected]>
Sat, 14 Jan 2012 04:46:26 +0000 (12:46 +0800)
committerJohn Hodge <[email protected]>
Sat, 14 Jan 2012 04:46:26 +0000 (12:46 +0800)
Modules/Display/VESA/main.c

index 6f056f3..55083b0 100644 (file)
@@ -51,6 +51,7 @@ tVM8086       *gpVesa_BiosState;
 tVesa_Mode     *gVesa_Modes;\r
 tVesa_Mode     *gpVesaCurMode;\r
  int   giVesaModeCount = 0;\r
+ int   gbVesaModesChecked;\r
 // --- Framebuffer ---\r
 char   *gpVesa_Framebuffer = (void*)VESA_DEFAULT_FRAMEBUFFER;\r
  int   giVesaPageCount = 0;    //!< Framebuffer size in pages\r
@@ -67,15 +68,12 @@ int Vesa_Install(char **Arguments)
 {\r
        tVesa_CallInfo  *info;\r
        tFarPtr infoPtr;\r
-       tVesa_CallModeInfo      *modeinfo;\r
-       tFarPtr modeinfoPtr;\r
        Uint16  *modes;\r
        int     i;\r
        \r
        // Allocate Info Block\r
        gpVesa_BiosState = VM8086_Init();\r
        info = VM8086_Allocate(gpVesa_BiosState, 512, &infoPtr.seg, &infoPtr.ofs);\r
-       modeinfo = VM8086_Allocate(gpVesa_BiosState, 512, &modeinfoPtr.seg, &modeinfoPtr.ofs);\r
        // Set Requested Version\r
        memcpy(info->signature, "VBE2", 4);\r
        // Set Registers\r
@@ -109,36 +107,9 @@ int Vesa_Install(char **Arguments)
        for( i = 1; i < giVesaModeCount; i++ )\r
        {\r
                gVesa_Modes[i].code = modes[i];\r
-               // Get Mode info\r
-               gpVesa_BiosState->AX = 0x4F01;\r
-               gpVesa_BiosState->CX = gVesa_Modes[i].code;\r
-               gpVesa_BiosState->ES = modeinfoPtr.seg;\r
-               gpVesa_BiosState->DI = modeinfoPtr.ofs;\r
-               VM8086_Int(gpVesa_BiosState, 0x10);\r
-               \r
-               // Parse Info\r
-               gVesa_Modes[i].flags = 0;\r
-               if ( (modeinfo->attributes & 0x90) == 0x90 )\r
-               {\r
-                       gVesa_Modes[i].flags |= FLAG_LFB;\r
-                       gVesa_Modes[i].framebuffer = modeinfo->physbase;\r
-                       gVesa_Modes[i].fbSize = modeinfo->Yres*modeinfo->pitch;\r
-               } else {\r
-                       gVesa_Modes[i].framebuffer = 0;\r
-                       gVesa_Modes[i].fbSize = 0;\r
-               }\r
-               \r
-               gVesa_Modes[i].pitch = modeinfo->pitch;\r
-               gVesa_Modes[i].width = modeinfo->Xres;\r
-               gVesa_Modes[i].height = modeinfo->Yres;\r
-               gVesa_Modes[i].bpp = modeinfo->bpp;\r
-               \r
-               #if DEBUG\r
-               Log_Log("VESA", "0x%x - %ix%ix%i",\r
-                       gVesa_Modes[i].code, gVesa_Modes[i].width, gVesa_Modes[i].height, gVesa_Modes[i].bpp);\r
-               #endif\r
        }\r
-       \r
+\r
+//     VM8086_Deallocate( info );\r
        \r
        // Install Device\r
        giVesaDriverId = DevFS_AddDevice( &gVesa_DriverStruct );\r
@@ -147,6 +118,53 @@ int Vesa_Install(char **Arguments)
        return MODULE_ERR_OK;\r
 }\r
 \r
+void Vesa_int_FillModeList(void)\r
+{\r
+       if( !gbVesaModesChecked )\r
+       {\r
+                int    i;\r
+               tVesa_CallModeInfo      *modeinfo;\r
+               tFarPtr modeinfoPtr;\r
+               \r
+               modeinfo = VM8086_Allocate(gpVesa_BiosState, 512, &modeinfoPtr.seg, &modeinfoPtr.ofs);\r
+               for( i = 1; i < giVesaModeCount; i ++ )\r
+               {\r
+                       // Get Mode info\r
+                       gpVesa_BiosState->AX = 0x4F01;\r
+                       gpVesa_BiosState->CX = gVesa_Modes[i].code;\r
+                       gpVesa_BiosState->ES = modeinfoPtr.seg;\r
+                       gpVesa_BiosState->DI = modeinfoPtr.ofs;\r
+                       VM8086_Int(gpVesa_BiosState, 0x10);\r
+                       \r
+                       // Parse Info\r
+                       gVesa_Modes[i].flags = 0;\r
+                       if ( (modeinfo->attributes & 0x90) == 0x90 )\r
+                       {\r
+                               gVesa_Modes[i].flags |= FLAG_LFB;\r
+                               gVesa_Modes[i].framebuffer = modeinfo->physbase;\r
+                               gVesa_Modes[i].fbSize = modeinfo->Yres*modeinfo->pitch;\r
+                       } else {\r
+                               gVesa_Modes[i].framebuffer = 0;\r
+                               gVesa_Modes[i].fbSize = 0;\r
+                       }\r
+                       \r
+                       gVesa_Modes[i].pitch = modeinfo->pitch;\r
+                       gVesa_Modes[i].width = modeinfo->Xres;\r
+                       gVesa_Modes[i].height = modeinfo->Yres;\r
+                       gVesa_Modes[i].bpp = modeinfo->bpp;\r
+                       \r
+                       #if DEBUG\r
+                       Log_Log("VESA", "0x%x - %ix%ix%i",\r
+                               gVesa_Modes[i].code, gVesa_Modes[i].width, gVesa_Modes[i].height, gVesa_Modes[i].bpp);\r
+                       #endif\r
+               }\r
+       \r
+//             VM8086_Deallocate( modeinfo );\r
+               \r
+               gbVesaModesChecked = 1;\r
+       }\r
+}\r
+\r
 /* Read from the framebuffer\r
  */\r
 Uint64 Vesa_Read(tVFS_Node *Node, Uint64 off, Uint64 len, void *buffer)\r
@@ -225,6 +243,8 @@ int Vesa_Int_SetMode(int mode)
        // Check for fast return\r
        if(mode == giVesaCurrentMode)   return 1;\r
        \r
+       Vesa_int_FillModeList();\r
+\r
        Time_RemoveTimer(giVesaCursorTimer);\r
        giVesaCursorTimer = -1;\r
        \r
@@ -274,6 +294,8 @@ int Vesa_Int_FindMode(tVideo_IOCtl_Mode *data)
         int    factor, tmp;\r
        \r
        ENTER("idata->width idata->height idata->bpp", data->width, data->height, data->bpp);\r
+\r
+       Vesa_int_FillModeList();\r
        \r
        for(i=0;i<giVesaModeCount;i++)\r
        {\r
@@ -329,6 +351,9 @@ int Vesa_Int_FindMode(tVideo_IOCtl_Mode *data)
 int Vesa_Int_ModeInfo(tVideo_IOCtl_Mode *data)\r
 {\r
        if(data->id < 0 || data->id > giVesaModeCount)  return -1;\r
+\r
+       Vesa_int_FillModeList();\r
+\r
        data->width = gVesa_Modes[data->id].width;\r
        data->height = gVesa_Modes[data->id].height;\r
        data->bpp = gVesa_Modes[data->id].bpp;\r

UCC git Repository :: git.ucc.asn.au