mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-04-01 03:51:31 +00:00
dm: video: Add driver-model support to vesa graphics
Provide a function to run the Vesa BIOS for a given PCI device and obtain the resulting configuration (e.g. display size) for use by the video uclass. This makes it easier to write a video driver that uses vesa and supports driver model. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
parent
d8441ea27e
commit
ee87ee82e1
2 changed files with 57 additions and 0 deletions
|
@ -31,6 +31,7 @@
|
||||||
#include <pci.h>
|
#include <pci.h>
|
||||||
#include <pci_rom.h>
|
#include <pci_rom.h>
|
||||||
#include <vbe.h>
|
#include <vbe.h>
|
||||||
|
#include <video.h>
|
||||||
#include <video_fb.h>
|
#include <video_fb.h>
|
||||||
#include <linux/screen_info.h>
|
#include <linux/screen_info.h>
|
||||||
|
|
||||||
|
@ -348,3 +349,57 @@ err:
|
||||||
free(ram);
|
free(ram);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_DM_VIDEO
|
||||||
|
static int vbe_setup_video_priv(struct vesa_mode_info *vesa,
|
||||||
|
struct video_priv *uc_priv,
|
||||||
|
struct video_uc_platdata *plat)
|
||||||
|
{
|
||||||
|
if (!vesa->x_resolution)
|
||||||
|
return -ENXIO;
|
||||||
|
uc_priv->xsize = vesa->x_resolution;
|
||||||
|
uc_priv->ysize = vesa->y_resolution;
|
||||||
|
switch (vesa->bits_per_pixel) {
|
||||||
|
case 32:
|
||||||
|
case 24:
|
||||||
|
uc_priv->bpix = VIDEO_BPP32;
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
uc_priv->bpix = VIDEO_BPP16;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -EPROTONOSUPPORT;
|
||||||
|
}
|
||||||
|
plat->base = vesa->phys_base_ptr;
|
||||||
|
plat->size = vesa->bytes_per_scanline * vesa->y_resolution;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int vbe_setup_video(struct udevice *dev, int (*int15_handler)(void))
|
||||||
|
{
|
||||||
|
struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
|
||||||
|
struct video_priv *uc_priv = dev_get_uclass_priv(dev);
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* If we are running from EFI or coreboot, this can't work */
|
||||||
|
if (!ll_boot_init())
|
||||||
|
return -EPERM;
|
||||||
|
bootstage_start(BOOTSTAGE_ID_ACCUM_LCD, "vesa display");
|
||||||
|
ret = dm_pci_run_vga_bios(dev, int15_handler, PCI_ROM_USE_NATIVE |
|
||||||
|
PCI_ROM_ALLOW_FALLBACK);
|
||||||
|
bootstage_accum(BOOTSTAGE_ID_ACCUM_LCD);
|
||||||
|
if (ret) {
|
||||||
|
debug("failed to run video BIOS: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = vbe_setup_video_priv(&mode_info.vesa, uc_priv, plat);
|
||||||
|
if (ret) {
|
||||||
|
debug("No video mode configured\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -106,5 +106,7 @@ extern struct vbe_mode_info mode_info;
|
||||||
|
|
||||||
struct graphic_device;
|
struct graphic_device;
|
||||||
int vbe_get_video_info(struct graphic_device *gdev);
|
int vbe_get_video_info(struct graphic_device *gdev);
|
||||||
|
struct video_priv;
|
||||||
|
int vbe_setup_video(struct udevice *dev, int (*int15_handler)(void));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue