]> git.sur5r.net Git - u-boot/blob - drivers/video/vesa_fb.c
cmd_usb_mass_storage: Remove extra 'ums' string in the usage text
[u-boot] / drivers / video / vesa_fb.c
1 /*
2  *
3  * Vesa frame buffer driver for x86
4  *
5  * Copyright (C) 2014 Google, Inc
6  *
7  * SPDX-License-Identifier:     GPL-2.0+
8  */
9
10 #include <common.h>
11 #include <pci_rom.h>
12 #include <video_fb.h>
13 #include <vbe.h>
14
15 /*
16  * The Graphic Device
17  */
18 GraphicDevice ctfb;
19
20 /* Devices to allow - only the last one works fully */
21 struct pci_device_id vesa_video_ids[] = {
22         { .vendor = 0x102b, .device = 0x0525 },
23         { .vendor = 0x1002, .device = 0x5159 },
24         { .vendor = 0x1002, .device = 0x4752 },
25         { .vendor = 0x1002, .device = 0x5452 },
26         { .vendor = 0x8086, .device = 0x0f31 },
27         {},
28 };
29
30 void *video_hw_init(void)
31 {
32         GraphicDevice *gdev = &ctfb;
33         int bits_per_pixel;
34         pci_dev_t dev;
35         int ret;
36
37         printf("Video: ");
38         if (vbe_get_video_info(gdev)) {
39                 /* TODO: Should we look these up by class? */
40                 dev = pci_find_devices(vesa_video_ids, 0);
41                 if (dev == -1) {
42                         printf("no card detected\n");
43                         return NULL;
44                 }
45                 bootstage_start(BOOTSTAGE_ID_ACCUM_LCD, "vesa display");
46                 ret = pci_run_vga_bios(dev, NULL, PCI_ROM_USE_NATIVE |
47                                        PCI_ROM_ALLOW_FALLBACK);
48                 bootstage_accum(BOOTSTAGE_ID_ACCUM_LCD);
49                 if (ret) {
50                         printf("failed to run video BIOS: %d\n", ret);
51                         return NULL;
52                 }
53         }
54
55         if (vbe_get_video_info(gdev)) {
56                 printf("No video mode configured\n");
57                 return NULL;
58         }
59
60         bits_per_pixel = gdev->gdfBytesPP * 8;
61         sprintf(gdev->modeIdent, "%dx%dx%d", gdev->winSizeX, gdev->winSizeY,
62                 bits_per_pixel);
63         printf("%s\n", gdev->modeIdent);
64         debug("Frame buffer at %x\n", gdev->pciBase);
65
66         return (void *)gdev;
67 }