]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
x86: Pass video settings from SPL to U-Boot proper
authorSimon Glass <sjg@chromium.org>
Sun, 16 Jul 2023 03:38:59 +0000 (21:38 -0600)
committerBin Meng <bmeng@tinylab.org>
Mon, 17 Jul 2023 09:12:26 +0000 (17:12 +0800)
When video is set up in SPL, U-Boot proper needs to use the correct
parameters so it can write to the display.

Put these in a bloblist so they are available to U-Boot proper.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Nikhil M Jain <n-jain1@ti.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
common/bloblist.c
drivers/pci/pci_rom.c
include/bloblist.h
include/video.h

index 0d63b6e88177b43d9b98f9654278f9d3b0270a60..2144b10e1d04f4cfcdd207fa6bb28069ab48ec67 100644 (file)
@@ -51,6 +51,7 @@ static struct tag_name {
 
        /* BLOBLISTT_PROJECT_AREA */
        { BLOBLISTT_U_BOOT_SPL_HANDOFF, "SPL hand-off" },
+       { BLOBLISTT_U_BOOT_VIDEO, "SPL video handoff" },
 
        /* BLOBLISTT_VENDOR_AREA */
 };
index 228ab7fca72897d71293437b2ff499f839a1468d..bdfd1f03e792be981804f3d1425eb2186c074733 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <common.h>
 #include <bios_emul.h>
+#include <bloblist.h>
 #include <bootstage.h>
 #include <dm.h>
 #include <errno.h>
@@ -34,6 +35,7 @@
 #include <malloc.h>
 #include <pci.h>
 #include <pci_rom.h>
+#include <spl.h>
 #include <vesa.h>
 #include <video.h>
 #include <acpi/acpi_s3.h>
@@ -374,34 +376,68 @@ int vesa_setup_video(struct udevice *dev, int (*int15_handler)(void))
                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);
-       bootstage_accum(BOOTSTAGE_ID_ACCUM_LCD);
-       if (ret) {
-               debug("failed to run video BIOS: %d\n", ret);
-               return ret;
-       }
 
-       ret = vesa_setup_video_priv(&mode_info.vesa,
-                                   mode_info.vesa.phys_base_ptr, uc_priv,
-                                   plat);
-       if (ret) {
-               if (ret == -ENFILE) {
-                       /*
-                        * See video-uclass.c for how to set up reserved memory
-                        * in your video driver
-                        */
-                       log_err("CONFIG_VIDEO_COPY enabled but driver '%s' set up no reserved memory\n",
-                               dev->driver->name);
+       /* In U-Boot proper, collect the information added by SPL (see below) */
+       if (IS_ENABLED(CONFIG_SPL_VIDEO) && spl_phase() > PHASE_SPL &&
+           CONFIG_IS_ENABLED(BLOBLIST)) {
+               struct video_handoff *ho;
+
+               ho = bloblist_find(BLOBLISTT_U_BOOT_VIDEO, sizeof(*ho));
+               if (!ho)
+                       return log_msg_ret("blf", -ENOENT);
+               plat->base = ho->fb;
+               plat->size = ho->size;
+               uc_priv->xsize = ho->xsize;
+               uc_priv->ysize = ho->ysize;
+               uc_priv->line_length = ho->line_length;
+               uc_priv->bpix = ho->bpix;
+       } else {
+               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;
                }
 
-               debug("No video mode configured\n");
-               return ret;
+               ret = vesa_setup_video_priv(&mode_info.vesa,
+                                           mode_info.vesa.phys_base_ptr,
+                                           uc_priv, plat);
+               if (ret) {
+                       if (ret == -ENFILE) {
+                               /*
+                                * See video-uclass.c for how to set up reserved
+                                * memory in your video driver
+                                */
+                               log_err("CONFIG_VIDEO_COPY enabled but driver '%s' set up no reserved memory\n",
+                                       dev->driver->name);
+                       }
+
+                       debug("No video mode configured\n");
+                       return ret;
+               }
        }
 
        printf("Video: %dx%dx%d\n", uc_priv->xsize, uc_priv->ysize,
               mode_info.vesa.bits_per_pixel);
 
+       /* In SPL, store the information for use by U-Boot proper */
+       if (spl_phase() == PHASE_SPL && CONFIG_IS_ENABLED(BLOBLIST)) {
+               struct video_handoff *ho;
+
+               ho = bloblist_add(BLOBLISTT_U_BOOT_VIDEO, sizeof(*ho), 0);
+               if (!ho)
+                       return log_msg_ret("blc", -ENOMEM);
+
+               ho->fb = plat->base;
+               ho->size = plat->size;
+               ho->xsize = uc_priv->xsize;
+               ho->ysize = uc_priv->ysize;
+               ho->line_length = uc_priv->line_length;
+               ho->bpix = uc_priv->bpix;
+       }
+
        return 0;
 }
index 2a2f1700eb09ba1eaa8bb2ac7aae64e893b429c3..7ea72c6bd46d1ba38307c6a6331235f7cd623a8d 100644 (file)
@@ -113,6 +113,7 @@ enum bloblist_tag_t {
        BLOBLISTT_PROJECT_AREA = 0x8000,
        BLOBLISTT_U_BOOT_SPL_HANDOFF = 0x8000, /* Hand-off info from SPL */
        BLOBLISTT_VBE           = 0x8001,       /* VBE per-phase state */
+       BLOBLISTT_U_BOOT_VIDEO = 0x8002, /* Video information from SPL */
 
        /*
         * Vendor-specific tags are permitted here. Projects can be open source
index e98d0f9c895db8e381b9f3559d34441f3e57bece..9729fa348aa5da9d48539ab6fb0a12983dfed98c 100644 (file)
@@ -134,6 +134,30 @@ struct video_ops {
 
 #define video_get_ops(dev)        ((struct video_ops *)(dev)->driver->ops)
 
+/**
+ * struct video_handoff - video information passed from SPL
+ *
+ * This is used when video is set up by SPL, to provide the details to U-Boot
+ * proper.
+ *
+ * @fb: Base address of frame buffer, 0 if not yet known
+ * @size: Frame-buffer size, in bytes
+ * @xsize:     Number of pixel columns (e.g. 1366)
+ * @ysize:     Number of pixels rows (e.g.. 768)
+ * @line_length:       Length of each frame buffer line, in bytes. This can be
+ *             set by the driver, but if not, the uclass will set it after
+ *             probing
+ * @bpix:      Encoded bits per pixel (enum video_log2_bpp)
+ */
+struct video_handoff {
+       u64 fb;
+       u32 size;
+       u16 xsize;
+       u16 ysize;
+       u32 line_length;
+       u8 bpix;
+};
+
 /** enum colour_idx - the 16 colors supported by consoles */
 enum colour_idx {
        VID_BLACK = 0,