[U-Boot] [PATCH 0/3] video patches

1/3 unchanged, 2/3 updated to use fdtdec_get_addr_size_auto_parent() to properly parse reg node based on #address-cells and #size-cells, and 3/3 updated to change kconfig name and slight cleanup.
Rob Clark (3): dm: core: also parse chosen node video: simplefb video: add config option to skip framebuffer clear
drivers/core/root.c | 22 +++++++++++++- drivers/video/Kconfig | 18 +++++++++++ drivers/video/Makefile | 2 +- drivers/video/cfb_console.c | 3 +- drivers/video/simplefb.c | 71 ++++++++++++++++++++++++++++++++++++++++++++ drivers/video/video-uclass.c | 4 ++- 6 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 drivers/video/simplefb.c

This is the node that would contain, for example, the framebuffer setup by an earlier stage.
Signed-off-by: Rob Clark robdclark@gmail.com --- drivers/core/root.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/core/root.c b/drivers/core/root.c index d691d6ff94..5e6b2da248 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -266,6 +266,26 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob, for (offset = fdt_first_subnode(blob, offset); offset > 0; offset = fdt_next_subnode(blob, offset)) { + ofnode node = offset_to_ofnode(offset); + + /* "chosen" node isn't a device itself but may contain some: */ + if (strcmp(ofnode_get_name(node), "chosen") == 0) { + dm_dbg("parsing subnodes of "chosen"\n"); + + for (node = ofnode_first_subnode(node); + ofnode_valid(node); + node = ofnode_next_subnode(node)) { + dm_dbg("subnode: %s\n", ofnode_get_name(node)); + err = lists_bind_fdt(parent, node, NULL); + if (err && !ret) { + ret = err; + dm_dbg("%s: ret=%d\n", ofnode_get_name(node), ret); + } + } + + continue; + } + if (pre_reloc_only && !dm_fdt_pre_reloc(blob, offset)) continue; @@ -273,7 +293,7 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob, dm_dbg(" - ignoring disabled device\n"); continue; } - err = lists_bind_fdt(parent, offset_to_ofnode(offset), NULL); + err = lists_bind_fdt(parent, node, NULL); if (err && !ret) { ret = err; debug("%s: ret=%d\n", fdt_get_name(blob, offset, NULL),

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 --- drivers/video/Kconfig | 10 +++++++ drivers/video/Makefile | 2 +- drivers/video/simplefb.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 drivers/video/simplefb.c
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 61dfed8c06..8eb0359231 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -628,4 +628,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 ac5371f2ae..52f50f647b 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -57,7 +57,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..035a9761b9 --- /dev/null +++ b/drivers/video/simplefb.c @@ -0,0 +1,71 @@ +/* + * (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, +};

The use-case is that the thing that loaded u-boot already put a splash image on screen. And we want to preserve that until grub boot menu takes over.
Signed-off-by: Rob Clark robdclark@gmail.com --- drivers/video/Kconfig | 8 ++++++++ drivers/video/cfb_console.c | 3 ++- drivers/video/video-uclass.c | 4 +++- 3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 8eb0359231..7b56b20344 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -98,6 +98,14 @@ config SYS_WHITE_ON_BLACK better in low-light situations or to reduce eye strain in some cases.
+config NO_FB_CLEAR + bool "Skip framebuffer clear" + help + If firmware (whatever loads u-boot) has already put a splash image + on screen, you might want to preserve it until whatever u-boots + loads takes over the screen. This, for example, can be used to + keep splash image on screen until grub graphical boot menu starts. + source "drivers/video/fonts/Kconfig"
config VIDCONSOLE_AS_LCD diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c index f54802052e..85fa5b0cae 100644 --- a/drivers/video/cfb_console.c +++ b/drivers/video/cfb_console.c @@ -2091,7 +2091,8 @@ static int cfg_video_init(void) } eorx = fgx ^ bgx;
- video_clear(); + if (!CONFIG_IS_ENABLED(NO_FB_CLEAR)) + video_clear();
#ifdef CONFIG_VIDEO_LOGO /* Plot the logo and get start point of console */ diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 3036e3a1f2..dfa39b0d1b 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -199,7 +199,9 @@ static int video_post_probe(struct udevice *dev) #else priv->colour_bg = 0xffffff; #endif - video_clear(dev); + + if (!CONFIG_IS_ENABLED(NO_FB_CLEAR)) + video_clear(dev);
/* * Create a text console device. For now we always do this, although
participants (1)
-
Rob Clark