This helper is used by the EFI driver and we would like to use that on
ARM. Move the helper function into its own file, separate from PCI ROMs,
which are an x86 thing.

Add a forward declaration for struct udevice so that the header can be
included directly.

Signed-off-by: Simon Glass <s...@chromium.org>
---

(no changes since v1)

 drivers/pci/pci_rom.c       | 32 -----------------------------
 drivers/video/Makefile      |  2 ++
 drivers/video/vesa_helper.c | 41 +++++++++++++++++++++++++++++++++++++
 include/vesa.h              |  2 ++
 4 files changed, 45 insertions(+), 32 deletions(-)
 create mode 100644 drivers/video/vesa_helper.c

diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
index 2753df275ca..35654ca89ac 100644
--- a/drivers/pci/pci_rom.c
+++ b/drivers/pci/pci_rom.c
@@ -334,38 +334,6 @@ err:
        return ret;
 }
 
-int vesa_setup_video_priv(struct vesa_mode_info *vesa, u64 fb,
-                         struct video_priv *uc_priv,
-                         struct video_uc_plat *plat)
-{
-       if (!vesa->x_resolution)
-               return log_msg_ret("No x resolution", -ENXIO);
-       uc_priv->xsize = vesa->x_resolution;
-       uc_priv->ysize = vesa->y_resolution;
-       uc_priv->line_length = vesa->bytes_per_scanline;
-       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;
-       }
-
-       /* Use double buffering if enabled */
-       if (IS_ENABLED(CONFIG_VIDEO_COPY) && plat->base)
-               plat->copy_base = fb;
-       else
-               plat->base = fb;
-       log_debug("base = %lx, copy_base = %lx\n", plat->base, plat->copy_base);
-       plat->size = vesa->bytes_per_scanline * vesa->y_resolution;
-
-       return 0;
-}
-
 int vesa_setup_video(struct udevice *dev, int (*int15_handler)(void))
 {
        struct video_uc_plat *plat = dev_get_uclass_plat(dev);
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 5a00438ce06..416a929d36b 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -27,6 +27,8 @@ obj-$(CONFIG_$(PHASE_)SIMPLE_PANEL) += simple_panel.o
 obj-$(CONFIG_VIDEO_LOGO) += u_boot_logo.o
 obj-$(CONFIG_$(PHASE_)BMP) += bmp.o
 
+obj-y += vesa_helper.o
+
 endif
 
 obj-$(CONFIG_BACKLIGHT_LM3533) += lm3533_backlight.o
diff --git a/drivers/video/vesa_helper.c b/drivers/video/vesa_helper.c
new file mode 100644
index 00000000000..dde8797e765
--- /dev/null
+++ b/drivers/video/vesa_helper.c
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025, Simon Glass <simon.gl...@canonical.com>
+ */
+
+#include <errno.h>
+#include <log.h>
+#include <vesa.h>
+#include <video.h>
+
+int vesa_setup_video_priv(struct vesa_mode_info *vesa, u64 fb,
+                         struct video_priv *uc_priv,
+                         struct video_uc_plat *plat)
+{
+       if (!vesa->x_resolution)
+               return log_msg_ret("No x resolution", -ENXIO);
+       uc_priv->xsize = vesa->x_resolution;
+       uc_priv->ysize = vesa->y_resolution;
+       uc_priv->line_length = vesa->bytes_per_scanline;
+       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;
+       }
+
+       /* Use double buffering if enabled */
+       if (IS_ENABLED(CONFIG_VIDEO_COPY) && plat->base)
+               plat->copy_base = fb;
+       else
+               plat->base = fb;
+       log_debug("base = %lx, copy_base = %lx\n", plat->base, plat->copy_base);
+       plat->size = vesa->bytes_per_scanline * vesa->y_resolution;
+
+       return 0;
+}
diff --git a/include/vesa.h b/include/vesa.h
index 9285bfa921a..abfc624e7cc 100644
--- a/include/vesa.h
+++ b/include/vesa.h
@@ -10,6 +10,8 @@
 #ifndef _VESA_H
 #define _VESA_H
 
+struct udevice;
+
 /* these structs are for input from and output to OF */
 struct __packed vesa_screen_info {
        u8 display_type;        /* 0=NONE, 1= analog, 2=digital */
-- 
2.43.0

Reply via email to