| @@ -19,7 +19,8 @@ enum efi_cmdline_option { · 18 unmodified lines |
| 19 | EFI_CMDLINE_NONE, | 19 | EFI_CMDLINE_NONE, |
| 20 | EFI_CMDLINE_MODE_NUM, | 20 | EFI_CMDLINE_MODE_NUM, |
| 21 | EFI_CMDLINE_RES, | 21 | EFI_CMDLINE_RES, |
| 22 | EFI_CMDLINE_AUTO | 22 | EFI_CMDLINE_AUTO, |
| | 23 | EFI_CMDLINE_LIST |
| 23 | }; | 24 | }; |
| 24 | | 25 | |
| 25 | static struct { | 26 | static struct { |
| @@ -100,6 +101,19 @@ static bool parse_auto(char *option, char **next) · 74 unmodified lines |
| 100 | return true; | 101 | return true; |
| 101 | } | 102 | } |
| 102 | | 103 | |
| | 104 | static bool parse_list(char *option, char **next) |
| | 105 | { |
| | 106 | if (!strstarts(option, "list")) |
| | 107 | return false; |
| | 108 | option += strlen("list"); |
| | 109 | if (*option && *option++ != ',') |
| | 110 | return false; |
| | 111 | cmdline.option = EFI_CMDLINE_LIST; |
| | 112 | |
| | 113 | *next = option; |
| | 114 | return true; |
| | 115 | } |
| | 116 | |
| 103 | void efi_parse_option_graphics(char *option) | 117 | void efi_parse_option_graphics(char *option) |
| 104 | { | 118 | { |
| 105 | while (*option) { | 119 | while (*option) { |
| @@ -109,6 +123,8 @@ void efi_parse_option_graphics(char *option) · 3 unmodified lines |
| 109 | continue; | 123 | continue; |
| 110 | if (parse_auto(option, &option)) | 124 | if (parse_auto(option, &option)) |
| 111 | continue; | 125 | continue; |
| | 126 | if (parse_list(option, &option)) |
| | 127 | continue; |
| 112 | | 128 | |
| 113 | while (*option && *option++ != ',') | 129 | while (*option && *option++ != ',') |
| 114 | ; | 130 | ; |
| @@ -290,6 +306,82 @@ static u32 choose_mode_auto(efi_graphics_output_protocol_t *gop) · 175 unmodified lines |
| 290 | return best_mode; | 306 | return best_mode; |
| 291 | } | 307 | } |
| 292 | | 308 | |
| | 309 | static u32 choose_mode_list(efi_graphics_output_protocol_t *gop) |
| | 310 | { |
| | 311 | efi_status_t status; |
| | 312 | |
| | 313 | efi_graphics_output_protocol_mode_t *mode; |
| | 314 | efi_graphics_output_mode_info_t *info; |
| | 315 | unsigned long info_size; |
| | 316 | |
| | 317 | u32 max_mode, cur_mode; |
| | 318 | int pf; |
| | 319 | efi_pixel_bitmask_t pi; |
| | 320 | u32 m, w, h; |
| | 321 | u8 d; |
| | 322 | const char *dstr; |
| | 323 | bool valid; |
| | 324 | efi_input_key_t key; |
| | 325 | |
| | 326 | mode = efi_table_attr(gop, mode); |
| | 327 | |
| | 328 | cur_mode = efi_table_attr(mode, mode); |
| | 329 | max_mode = efi_table_attr(mode, max_mode); |
| | 330 | |
| | 331 | efi_printk("Available graphics modes are 0-%u\n", max_mode-1); |
| | 332 | efi_puts(" * = current mode\n" |
| | 333 | " - = unusable mode\n"); |
| | 334 | for (m = 0; m < max_mode; m++) { |
| | 335 | status = efi_call_proto(gop, query_mode, m, |
| | 336 | &info_size, &info); |
| | 337 | if (status != EFI_SUCCESS) |
| | 338 | continue; |
| | 339 | |
| | 340 | pf = info->pixel_format; |
| | 341 | pi = info->pixel_information; |
| | 342 | w = info->horizontal_resolution; |
| | 343 | h = info->vertical_resolution; |
| | 344 | |
| | 345 | efi_bs_call(free_pool, info); |
| | 346 | |
| | 347 | valid = !(pf == PIXEL_BLT_ONLY || pf >= PIXEL_FORMAT_MAX); |
| | 348 | d = 0; |
| | 349 | switch (pf) { |
| | 350 | case PIXEL_RGB_RESERVED_8BIT_PER_COLOR: |
| | 351 | dstr = "rgb"; |
| | 352 | break; |
| | 353 | case PIXEL_BGR_RESERVED_8BIT_PER_COLOR: |
| | 354 | dstr = "bgr"; |
| | 355 | break; |
| | 356 | case PIXEL_BIT_MASK: |
| | 357 | dstr = ""; |
| | 358 | d = pixel_bpp(pf, pi); |
| | 359 | break; |
| | 360 | case PIXEL_BLT_ONLY: |
| | 361 | dstr = "blt"; |
| | 362 | break; |
| | 363 | default: |
| | 364 | dstr = "xxx"; |
| | 365 | break; |
| | 366 | } |
| | 367 | |
| | 368 | efi_printk("Mode %3u %c%c: Resolution %ux%u-%s%.0hhu\n", |
| | 369 | m, |
| | 370 | m == cur_mode ? '*' : ' ', |
| | 371 | !valid ? '-' : ' ', |
| | 372 | w, h, dstr, d); |
| | 373 | } |
| | 374 | |
| | 375 | efi_puts("\nPress any key to continue (or wait 10 seconds)\n"); |
| | 376 | status = efi_wait_for_key(10 * EFI_USEC_PER_SEC, &key); |
| | 377 | if (status != EFI_SUCCESS && status != EFI_TIMEOUT) { |
| | 378 | efi_err("Unable to read key, continuing in 10 seconds\n"); |
| | 379 | efi_bs_call(stall, 10 * EFI_USEC_PER_SEC); |
| | 380 | } |
| | 381 | |
| | 382 | return cur_mode; |
| | 383 | } |
| | 384 | |
| 293 | static void set_mode(efi_graphics_output_protocol_t *gop) | 385 | static void set_mode(efi_graphics_output_protocol_t *gop) |
| 294 | { | 386 | { |
| 295 | efi_graphics_output_protocol_mode_t *mode; | 387 | efi_graphics_output_protocol_mode_t *mode; |
| @@ -305,6 +397,9 @@ static void set_mode(efi_graphics_output_protocol_t *gop) · 9 unmodified lines |
| 305 | case EFI_CMDLINE_AUTO: | 397 | case EFI_CMDLINE_AUTO: |
| 306 | new_mode = choose_mode_auto(gop); | 398 | new_mode = choose_mode_auto(gop); |
| 307 | break; | 399 | break; |
| | 400 | case EFI_CMDLINE_LIST: |
| | 401 | new_mode = choose_mode_list(gop); |
| | 402 | break; |
| 308 | default: | 403 | default: |
| 309 | return; | 404 | return; |
| 310 | } | 405 | } |