- ModeSet = (Status == EFI_SUCCESS);
- } // if
- } while (((++ModeNum < MIN_SCAN_GRAPHICS_MODES) || (Status == EFI_SUCCESS)) && !ModeSet);
-// while ((Status == EFI_SUCCESS) && (!ModeSet)) {
-// Status = refit_call4_wrapper(GraphicsOutput->QueryMode, GraphicsOutput, ModeNum, &Size, &Info);
-// if ((Status == EFI_SUCCESS) && (Size >= sizeof(*Info)) &&
-// (Info->HorizontalResolution == *ScreenWidth) && (Info->VerticalResolution == *ScreenHeight)) {
-// Status = refit_call2_wrapper(GraphicsOutput->SetMode, GraphicsOutput, ModeNum);
-// ModeSet = (Status == EFI_SUCCESS);
-// } // if
-// ModeNum++;
-// } // while()
+ if (Status == EFI_SUCCESS) {
+ ModeSet = TRUE;
+ *ScreenWidth = Info->HorizontalResolution;
+ *ScreenHeight = Info->VerticalResolution;
+ } // if set mode OK
+ } // if queried mode OK
+ } // if/else
+
+ // User specified width & height; must find mode -- but only if change is required....
+ } else {
+ Status = refit_call4_wrapper(GraphicsOutput->QueryMode, GraphicsOutput, GraphicsOutput->Mode->Mode, &Size, &Info);
+ if ((Status == EFI_SUCCESS) && (Info->HorizontalResolution == *ScreenWidth) &&
+ (Info->VerticalResolution == *ScreenHeight)) {
+ ModeSet = TRUE; // user requested current mode; do nothing
+ } else {
+ // Do a loop through the modes to see if the specified one is available;
+ // and if so, switch to it....
+ do {
+ Status = refit_call4_wrapper(GraphicsOutput->QueryMode, GraphicsOutput, ModeNum, &Size, &Info);
+ if ((Status == EFI_SUCCESS) && (Size >= sizeof(*Info)) &&
+ (Info->HorizontalResolution == *ScreenWidth) && (Info->VerticalResolution == *ScreenHeight)) {
+ Status = refit_call2_wrapper(GraphicsOutput->SetMode, GraphicsOutput, ModeNum);
+ ModeSet = (Status == EFI_SUCCESS);
+ } // if
+ } while ((++ModeNum < GraphicsOutput->Mode->MaxMode) && !ModeSet);
+ } // if/else