MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / egSetScreenResolution

Function egSetScreenResolution

rEFIt_UEFI/libeg/libscreen.cpp:300–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300EFI_STATUS egSetScreenResolution(IN const CHAR16 *WidthHeight)
301{
302 EFI_STATUS Status = EFI_UNSUPPORTED;
303 UINT32 Width;
304 UINT32 Height;
305 const CHAR16 *HeightP;
306 UINT32 MaxMode;
307 UINT32 Mode;
308 UINTN SizeOfInfo;
309 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
310
311 if (GraphicsOutput == NULL) {
312 return EFI_UNSUPPORTED;
313 }
314
315 if (WidthHeight == NULL) {
316 return EFI_INVALID_PARAMETER;
317 }
318 MsgLog("SetScreenResolution: %ls", WidthHeight);
319 // we are expecting WidthHeight=L"1024x768"
320 // parse Width and Height
321 HeightP = WidthHeight;
322 while (*HeightP != L'\0' && *HeightP != L'x' && *HeightP != L'X') {
323 HeightP++;
324 }
325 if (*HeightP == L'\0') {
326 return EFI_INVALID_PARAMETER;
327 }
328 HeightP++;
329 Width = (UINT32)StrDecimalToUintn(WidthHeight);
330 Height = (UINT32)StrDecimalToUintn(HeightP);
331
332 // check if requested mode is equal to current mode
333 if ((GraphicsOutput->Mode->Info->HorizontalResolution == Width) && (GraphicsOutput->Mode->Info->VerticalResolution == Height)) {
334 MsgLog(" - already set\n");
335 egScreenWidth = GraphicsOutput->Mode->Info->HorizontalResolution;
336 egScreenHeight = GraphicsOutput->Mode->Info->VerticalResolution;
337 return EFI_SUCCESS;
338 }
339
340 // iterate through modes and set it if found
341 MaxMode = GraphicsOutput->Mode->MaxMode;
342 for (Mode = 0; Mode < MaxMode; Mode++) {
343 Status = GraphicsOutput->QueryMode(GraphicsOutput, Mode, &SizeOfInfo, &Info);
344 if (Status == EFI_SUCCESS) {
345 if (Width == Info->HorizontalResolution && Height == Info->VerticalResolution) {
346 MsgLog(" - setting Mode %d\n", Mode);
347 //Status = GraphicsOutput->SetMode(GraphicsOutput, Mode);
348 Status = GopSetModeAndReconnectTextOut(Mode);
349 if (Status == EFI_SUCCESS) {
350 egScreenWidth = Width;
351 egScreenHeight = Height;
352 return EFI_SUCCESS;
353 }
354 }
355 }
356 }
357 MsgLog(" - not found!\n");

Callers 1

egInitScreenFunction · 0.85

Calls 2

StrDecimalToUintnFunction · 0.85

Tested by

no test coverage detected