]>
Commit | Line | Data |
---|---|---|
6b1ba984 | 1 | /* |
b018a8c7 | 2 | * VESA frame buffer driver |
6b1ba984 SG |
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 | ||
6b1ba984 SG |
19 | void *video_hw_init(void) |
20 | { | |
21 | GraphicDevice *gdev = &ctfb; | |
3f4e1e8e | 22 | struct udevice *dev; |
6b1ba984 | 23 | int bits_per_pixel; |
6b1ba984 SG |
24 | int ret; |
25 | ||
26 | printf("Video: "); | |
ad11dbff SG |
27 | if (!ll_boot_init()) { |
28 | /* | |
29 | * If we are running from EFI or coreboot, this driver can't | |
30 | * work. | |
31 | */ | |
32 | printf("Not available (previous bootloader prevents it)\n"); | |
33 | return NULL; | |
34 | } | |
6b1ba984 | 35 | if (vbe_get_video_info(gdev)) { |
3f4e1e8e SG |
36 | ret = dm_pci_find_class(PCI_CLASS_DISPLAY_VGA << 8, 0, &dev); |
37 | if (ret) { | |
6b1ba984 SG |
38 | printf("no card detected\n"); |
39 | return NULL; | |
40 | } | |
ef565a53 | 41 | bootstage_start(BOOTSTAGE_ID_ACCUM_LCD, "vesa display"); |
3f4e1e8e SG |
42 | ret = dm_pci_run_vga_bios(dev, NULL, PCI_ROM_USE_NATIVE | |
43 | PCI_ROM_ALLOW_FALLBACK); | |
ef565a53 | 44 | bootstage_accum(BOOTSTAGE_ID_ACCUM_LCD); |
6b1ba984 SG |
45 | if (ret) { |
46 | printf("failed to run video BIOS: %d\n", ret); | |
47 | return NULL; | |
48 | } | |
49 | } | |
50 | ||
51 | if (vbe_get_video_info(gdev)) { | |
52 | printf("No video mode configured\n"); | |
53 | return NULL; | |
54 | } | |
55 | ||
56 | bits_per_pixel = gdev->gdfBytesPP * 8; | |
57 | sprintf(gdev->modeIdent, "%dx%dx%d", gdev->winSizeX, gdev->winSizeY, | |
58 | bits_per_pixel); | |
59 | printf("%s\n", gdev->modeIdent); | |
bc17d8f4 | 60 | debug("Frame buffer at %x\n", gdev->pciBase); |
6b1ba984 SG |
61 | |
62 | return (void *)gdev; | |
63 | } |