summaryrefslogtreecommitdiff
path: root/drivers/video
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2017-08-03 12:47:00 -0400
committerAnatolij Gustschin <agust@denx.de>2017-09-12 13:40:47 +0200
commit971d7e64245d5970ae9fe9a1f418e2900663248a (patch)
treec636a65e39379a7ff64b5ee08396c3321516eb1b /drivers/video
parent72719d2f8ae5022fb45d3020d85a644da8884f2a (diff)
video: simplefb
Not really qcom specific, but for now qcom/lk is the one firmware that is (afaiu) setting up the appropriate dt node for pre-configured display. Uses the generic simple-framebuffer DT bindings so this should be useful on other platforms. Signed-off-by: Rob Clark <robdclark@gmail.com>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/Kconfig10
-rw-r--r--drivers/video/Makefile2
-rw-r--r--drivers/video/simplefb.c73
3 files changed, 84 insertions, 1 deletions
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 9c6430c903..5505ee6f57 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -624,4 +624,14 @@ config VIDEO_DW_HDMI
rather requires a SoC-specific glue driver to call it), it
can not be enabled from the configuration menu.
+config VIDEO_SIMPLE
+ bool "Simple display driver for preconfigured display"
+ help
+ Enables a simple generic display driver which utilizes the
+ simple-framebuffer devicetree bindings.
+
+ This driver assumes that the display hardware has been initialized
+ before u-boot starts, and u-boot will simply render to the pre-
+ allocated frame buffer surface.
+
endmenu
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index ef4d30b3f3..dfafe08fc5 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -52,7 +52,7 @@ obj-$(CONFIG_FORMIKE) += formike.o
obj-$(CONFIG_LG4573) += lg4573.o
obj-$(CONFIG_AM335X_LCD) += am335x-fb.o
obj-$(CONFIG_VIDEO_DW_HDMI) += dw_hdmi.o
-
+obj-$(CONFIG_VIDEO_SIMPLE) += simplefb.o
obj-${CONFIG_VIDEO_TEGRA124} += tegra124/
obj-${CONFIG_EXYNOS_FB} += exynos/
obj-${CONFIG_VIDEO_ROCKCHIP} += rockchip/
diff --git a/drivers/video/simplefb.c b/drivers/video/simplefb.c
new file mode 100644
index 0000000000..850a279d64
--- /dev/null
+++ b/drivers/video/simplefb.c
@@ -0,0 +1,73 @@
+/*
+ * (C) Copyright 2017 Rob Clark
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <fdtdec.h>
+#include <fdt_support.h>
+#include <video.h>
+
+static int simple_video_probe(struct udevice *dev)
+{
+ struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
+ struct video_priv *uc_priv = dev_get_uclass_priv(dev);
+ const void *blob = gd->fdt_blob;
+ const int node = dev_of_offset(dev);
+ const char *format;
+ fdt_addr_t base;
+ fdt_size_t size;
+
+ base = fdtdec_get_addr_size_auto_parent(blob, dev_of_offset(dev->parent),
+ node, "reg", 0, &size, false);
+ if (base == FDT_ADDR_T_NONE) {
+ debug("%s: Failed to decode memory region\n", __func__);
+ return -EINVAL;
+ }
+
+ debug("%s: base=%llx, size=%llu\n", __func__, base, size);
+
+ /*
+ * TODO is there some way to reserve the framebuffer
+ * region so it isn't clobbered?
+ */
+ plat->base = base;
+ plat->size = size;
+
+ video_set_flush_dcache(dev, true);
+
+ debug("%s: Query resolution...\n", __func__);
+
+ uc_priv->xsize = fdtdec_get_uint(blob, node, "width", 0);
+ uc_priv->ysize = fdtdec_get_uint(blob, node, "height", 0);
+ uc_priv->rot = 0;
+
+ format = fdt_getprop(blob, node, "format", NULL);
+ debug("%s: %dx%d@%s\n", __func__, uc_priv->xsize, uc_priv->ysize, format);
+
+ if (strcmp(format, "r5g6b5") == 0) {
+ uc_priv->bpix = VIDEO_BPP16;
+ } else if (strcmp(format, "a8b8g8r8") == 0) {
+ uc_priv->bpix = VIDEO_BPP32;
+ } else {
+ printf("%s: invalid format: %s\n", __func__, format);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static const struct udevice_id simple_video_ids[] = {
+ { .compatible = "simple-framebuffer" },
+ { }
+};
+
+U_BOOT_DRIVER(simple_video) = {
+ .name = "simple_video",
+ .id = UCLASS_VIDEO,
+ .of_match = simple_video_ids,
+ .probe = simple_video_probe,
+ .flags = DM_FLAG_PRE_RELOC,
+};