2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2017-08-03 16:47:00 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2017 Rob Clark
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <fdtdec.h>
|
|
|
|
#include <fdt_support.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2017-08-03 16:47:00 +00:00
|
|
|
#include <video.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2017-08-03 16:47:00 +00:00
|
|
|
|
|
|
|
static int simple_video_probe(struct udevice *dev)
|
|
|
|
{
|
2020-12-03 23:55:23 +00:00
|
|
|
struct video_uc_plat *plat = dev_get_uclass_plat(dev);
|
2017-08-03 16:47:00 +00:00
|
|
|
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;
|
2021-09-25 20:47:38 +00:00
|
|
|
} else if (strcmp(format, "a8b8g8r8") == 0 ||
|
|
|
|
strcmp(format, "x8b8g8r8") == 0) {
|
2017-08-03 16:47:00 +00:00
|
|
|
uc_priv->bpix = VIDEO_BPP32;
|
2021-09-25 20:47:38 +00:00
|
|
|
uc_priv->format = VIDEO_X8B8G8R8;
|
|
|
|
} else if (strcmp(format, "a8r8g8b8") == 0 ||
|
|
|
|
strcmp(format, "x8r8g8b8") == 0) {
|
|
|
|
uc_priv->bpix = VIDEO_BPP32;
|
|
|
|
uc_priv->format = VIDEO_X8R8G8B8;
|
|
|
|
} else if (strcmp(format, "a2r10g10b10") == 0 ||
|
|
|
|
strcmp(format, "x2r10g10b10") == 0) {
|
|
|
|
uc_priv->bpix = VIDEO_BPP32;
|
|
|
|
uc_priv->format = VIDEO_X2R10G10B10;
|
2017-08-03 16:47:00 +00:00
|
|
|
} 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,
|
|
|
|
};
|