Simon Glass | 6b1ba98 | 2014-12-29 19:32:28 -0700 | [diff] [blame] | 1 | /* |
Bin Meng | b018a8c | 2015-07-06 16:31:26 +0800 | [diff] [blame] | 2 | * VESA frame buffer driver |
Simon Glass | 6b1ba98 | 2014-12-29 19:32:28 -0700 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2014 Google, Inc |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <pci_rom.h> |
| 11 | #include <video_fb.h> |
| 12 | #include <vbe.h> |
| 13 | |
| 14 | /* |
| 15 | * The Graphic Device |
| 16 | */ |
| 17 | GraphicDevice ctfb; |
| 18 | |
Simon Glass | 6b1ba98 | 2014-12-29 19:32:28 -0700 | [diff] [blame] | 19 | void *video_hw_init(void) |
| 20 | { |
| 21 | GraphicDevice *gdev = &ctfb; |
| 22 | int bits_per_pixel; |
| 23 | pci_dev_t dev; |
| 24 | int ret; |
| 25 | |
| 26 | printf("Video: "); |
| 27 | if (vbe_get_video_info(gdev)) { |
Bin Meng | b018a8c | 2015-07-06 16:31:26 +0800 | [diff] [blame] | 28 | dev = pci_find_class(PCI_CLASS_DISPLAY_VGA << 8, 0); |
Simon Glass | 6b1ba98 | 2014-12-29 19:32:28 -0700 | [diff] [blame] | 29 | if (dev == -1) { |
| 30 | printf("no card detected\n"); |
| 31 | return NULL; |
| 32 | } |
Simon Glass | ef565a5 | 2015-01-27 22:13:35 -0700 | [diff] [blame] | 33 | bootstage_start(BOOTSTAGE_ID_ACCUM_LCD, "vesa display"); |
Simon Glass | bc17d8f | 2015-01-27 22:13:34 -0700 | [diff] [blame] | 34 | ret = pci_run_vga_bios(dev, NULL, PCI_ROM_USE_NATIVE | |
| 35 | PCI_ROM_ALLOW_FALLBACK); |
Simon Glass | ef565a5 | 2015-01-27 22:13:35 -0700 | [diff] [blame] | 36 | bootstage_accum(BOOTSTAGE_ID_ACCUM_LCD); |
Simon Glass | 6b1ba98 | 2014-12-29 19:32:28 -0700 | [diff] [blame] | 37 | if (ret) { |
| 38 | printf("failed to run video BIOS: %d\n", ret); |
| 39 | return NULL; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | if (vbe_get_video_info(gdev)) { |
| 44 | printf("No video mode configured\n"); |
| 45 | return NULL; |
| 46 | } |
| 47 | |
| 48 | bits_per_pixel = gdev->gdfBytesPP * 8; |
| 49 | sprintf(gdev->modeIdent, "%dx%dx%d", gdev->winSizeX, gdev->winSizeY, |
| 50 | bits_per_pixel); |
| 51 | printf("%s\n", gdev->modeIdent); |
Simon Glass | bc17d8f | 2015-01-27 22:13:34 -0700 | [diff] [blame] | 52 | debug("Frame buffer at %x\n", gdev->pciBase); |
Simon Glass | 6b1ba98 | 2014-12-29 19:32:28 -0700 | [diff] [blame] | 53 | |
| 54 | return (void *)gdev; |
| 55 | } |