From ee87ee82e1c9052d59e44c5c29448f4545ab59e7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 5 Oct 2016 20:42:17 -0600 Subject: 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 Reviewed-by: Bin Meng --- drivers/pci/pci_rom.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'drivers/pci/pci_rom.c') diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c index 399055b078..21ed17c0a0 100644 --- a/drivers/pci/pci_rom.c +++ b/drivers/pci/pci_rom.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -348,3 +349,57 @@ err: free(ram); 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 -- cgit v1.2.3 From f0920e4a4498294bf8328db37638f47bccf04b3f Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Sun, 9 Oct 2016 04:14:12 -0700 Subject: dm: video: Output verbose information in vbe_setup_video() With DM conversion, information like "Video: 1024x768x16" is not shown anymore. Now add these verbose output back. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- drivers/pci/pci_rom.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'drivers/pci/pci_rom.c') diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c index 21ed17c0a0..5746c3d551 100644 --- a/drivers/pci/pci_rom.c +++ b/drivers/pci/pci_rom.c @@ -382,9 +382,13 @@ int vbe_setup_video(struct udevice *dev, int (*int15_handler)(void)) struct video_priv *uc_priv = dev_get_uclass_priv(dev); int ret; + printf("Video: "); + /* If we are running from EFI or coreboot, this can't work */ - if (!ll_boot_init()) + if (!ll_boot_init()) { + printf("Not available (previous bootloader prevents it)\n"); 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); @@ -400,6 +404,9 @@ int vbe_setup_video(struct udevice *dev, int (*int15_handler)(void)) return ret; } + printf("%dx%dx%d\n", uc_priv->xsize, uc_priv->ysize, + mode_info.vesa.bits_per_pixel); + return 0; } #endif -- cgit v1.2.3 From 5f6ad029f31e897fa8bd62d3f42092e051932bc2 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Sun, 9 Oct 2016 04:14:15 -0700 Subject: vbe: Make vbe_setup_video_priv() public vbe_setup_video_priv() might be useful to other drivers. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- drivers/pci/pci_rom.c | 6 +++--- include/vbe.h | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'drivers/pci/pci_rom.c') diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c index 5746c3d551..cd083f7dde 100644 --- a/drivers/pci/pci_rom.c +++ b/drivers/pci/pci_rom.c @@ -351,9 +351,9 @@ err: } #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) +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; diff --git a/include/vbe.h b/include/vbe.h index a743892d27..16bb096236 100644 --- a/include/vbe.h +++ b/include/vbe.h @@ -107,6 +107,10 @@ extern struct vbe_mode_info mode_info; struct graphic_device; int vbe_get_video_info(struct graphic_device *gdev); struct video_priv; +struct video_uc_platdata; +int vbe_setup_video_priv(struct vesa_mode_info *vesa, + struct video_priv *uc_priv, + struct video_uc_platdata *plat); int vbe_setup_video(struct udevice *dev, int (*int15_handler)(void)); #endif -- cgit v1.2.3