All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 09/12] dm: video: Add driver-model support to vesa graphics
Date: Wed,  5 Oct 2016 20:42:17 -0600	[thread overview]
Message-ID: <1475721740-15124-10-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1475721740-15124-1-git-send-email-sjg@chromium.org>

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>
---

Changes in v2:
- Make vbe_setup_video_priv() static

 drivers/pci/pci_rom.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++
 include/vbe.h         |  2 ++
 2 files changed, 57 insertions(+)

diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
index 399055b..21ed17c 100644
--- a/drivers/pci/pci_rom.c
+++ b/drivers/pci/pci_rom.c
@@ -31,6 +31,7 @@
 #include <pci.h>
 #include <pci_rom.h>
 #include <vbe.h>
+#include <video.h>
 #include <video_fb.h>
 #include <linux/screen_info.h>
 
@@ -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
diff --git a/include/vbe.h b/include/vbe.h
index 164ccae..a743892 100644
--- a/include/vbe.h
+++ b/include/vbe.h
@@ -106,5 +106,7 @@ extern struct vbe_mode_info mode_info;
 
 struct graphic_device;
 int vbe_get_video_info(struct graphic_device *gdev);
+struct video_priv;
+int vbe_setup_video(struct udevice *dev, int (*int15_handler)(void));
 
 #endif
-- 
2.8.0.rc3.226.g39d4020

  parent reply	other threads:[~2016-10-06  2:42 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-06  2:42 [U-Boot] [PATCH v2 00/12] dm: x86: Improve vesa driver-model support Simon Glass
2016-10-06  2:42 ` [U-Boot] [PATCH v2 01/12] Revert "x86: broadwell: gpio: Remove the codes to set up pin control" Simon Glass
2016-10-08  4:23   ` Bin Meng
2016-10-06  2:42 ` [U-Boot] [PATCH v2 02/12] x86: Add an accelerated memmove() function Simon Glass
2016-10-08  2:25   ` Bin Meng
2016-10-08  4:23     ` Bin Meng
2016-10-08  5:53     ` Bin Meng
2016-10-10  2:05       ` Bin Meng
2016-10-13  0:03         ` Simon Glass
2016-10-06  2:42 ` [U-Boot] [PATCH v2 03/12] Fix return value in trailing_strtoln() Simon Glass
2016-10-08  4:23   ` Bin Meng
2016-10-06  2:42 ` [U-Boot] [PATCH v2 04/12] list: Add list_last_entry() to find the last entry Simon Glass
2016-10-08  4:23   ` Bin Meng
2016-10-06  2:42 ` [U-Boot] [PATCH v2 05/12] dm: core: Add a function to get a uclass name Simon Glass
2016-10-08  4:23   ` Bin Meng
2016-10-06  2:42 ` [U-Boot] [PATCH v2 06/12] x86: video: Fix typo in broadwell Kconfig Simon Glass
2016-10-08  4:23   ` Bin Meng
2016-10-06  2:42 ` [U-Boot] [PATCH v2 07/12] dm: x86: video: Add a driver-model driver for ivybridge graphics Simon Glass
2016-10-08  2:33   ` Bin Meng
2016-10-08  4:23     ` Bin Meng
2016-10-06  2:42 ` [U-Boot] [PATCH v2 08/12] dm: stdio: Allow lazy probing of video devices Simon Glass
2016-10-08  2:32   ` Bin Meng
2016-10-08  4:23     ` Bin Meng
2016-10-06  2:42 ` Simon Glass [this message]
2016-10-08  4:24   ` [U-Boot] [PATCH v2 09/12] dm: video: Add driver-model support to vesa graphics Bin Meng
2016-10-06  2:42 ` [U-Boot] [PATCH v2 10/12] x86: Adjust config to support DM_VIDEO Simon Glass
2016-10-08  4:24   ` Bin Meng
2016-10-06  2:42 ` [U-Boot] [PATCH v2 11/12] dm: x86: Move samus to use new driver model support Simon Glass
2016-10-08  4:24   ` Bin Meng
2016-10-06  2:42 ` [U-Boot] [PATCH v2 12/12] dm: x86: Move link to use driver model for video Simon Glass
2016-10-08  4:24   ` Bin Meng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475721740-15124-10-git-send-email-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.