2014-12-30 02:32:28 +00:00
|
|
|
/*
|
2015-07-06 08:31:26 +00:00
|
|
|
* VESA frame buffer driver
|
2014-12-30 02:32:28 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Google, Inc
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <pci_rom.h>
|
|
|
|
#include <video_fb.h>
|
|
|
|
#include <vbe.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The Graphic Device
|
|
|
|
*/
|
|
|
|
GraphicDevice ctfb;
|
|
|
|
|
|
|
|
void *video_hw_init(void)
|
|
|
|
{
|
|
|
|
GraphicDevice *gdev = &ctfb;
|
|
|
|
int bits_per_pixel;
|
|
|
|
pci_dev_t dev;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
printf("Video: ");
|
2015-08-04 18:34:04 +00:00
|
|
|
if (!ll_boot_init()) {
|
|
|
|
/*
|
|
|
|
* If we are running from EFI or coreboot, this driver can't
|
|
|
|
* work.
|
|
|
|
*/
|
|
|
|
printf("Not available (previous bootloader prevents it)\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-12-30 02:32:28 +00:00
|
|
|
if (vbe_get_video_info(gdev)) {
|
2015-07-06 08:31:26 +00:00
|
|
|
dev = pci_find_class(PCI_CLASS_DISPLAY_VGA << 8, 0);
|
2015-10-01 07:36:00 +00:00
|
|
|
if (dev < 0) {
|
2014-12-30 02:32:28 +00:00
|
|
|
printf("no card detected\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-01-28 05:13:35 +00:00
|
|
|
bootstage_start(BOOTSTAGE_ID_ACCUM_LCD, "vesa display");
|
2015-01-28 05:13:34 +00:00
|
|
|
ret = pci_run_vga_bios(dev, NULL, PCI_ROM_USE_NATIVE |
|
|
|
|
PCI_ROM_ALLOW_FALLBACK);
|
2015-01-28 05:13:35 +00:00
|
|
|
bootstage_accum(BOOTSTAGE_ID_ACCUM_LCD);
|
2014-12-30 02:32:28 +00:00
|
|
|
if (ret) {
|
|
|
|
printf("failed to run video BIOS: %d\n", ret);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vbe_get_video_info(gdev)) {
|
|
|
|
printf("No video mode configured\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bits_per_pixel = gdev->gdfBytesPP * 8;
|
|
|
|
sprintf(gdev->modeIdent, "%dx%dx%d", gdev->winSizeX, gdev->winSizeY,
|
|
|
|
bits_per_pixel);
|
|
|
|
printf("%s\n", gdev->modeIdent);
|
2015-01-28 05:13:34 +00:00
|
|
|
debug("Frame buffer at %x\n", gdev->pciBase);
|
2014-12-30 02:32:28 +00:00
|
|
|
|
|
|
|
return (void *)gdev;
|
|
|
|
}
|