2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-02-27 20:26:19 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 Google, Inc
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2016-01-19 02:52:25 +00:00
|
|
|
#include <dm.h>
|
2014-02-27 20:26:19 +00:00
|
|
|
#include <fdtdec.h>
|
2016-01-19 02:52:25 +00:00
|
|
|
#include <video.h>
|
2014-02-27 20:26:19 +00:00
|
|
|
#include <asm/sdl.h>
|
|
|
|
#include <asm/u-boot-sandbox.h>
|
2016-01-19 02:52:25 +00:00
|
|
|
#include <dm/test.h>
|
2014-02-27 20:26:19 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
enum {
|
2016-01-19 02:52:25 +00:00
|
|
|
/* Default LCD size we support */
|
2014-02-27 20:26:19 +00:00
|
|
|
LCD_MAX_WIDTH = 1366,
|
|
|
|
LCD_MAX_HEIGHT = 768,
|
|
|
|
};
|
|
|
|
|
2016-01-19 02:52:25 +00:00
|
|
|
static int sandbox_sdl_probe(struct udevice *dev)
|
2014-02-27 20:26:19 +00:00
|
|
|
{
|
2016-01-19 02:52:25 +00:00
|
|
|
struct sandbox_sdl_plat *plat = dev_get_platdata(dev);
|
|
|
|
struct video_priv *uc_priv = dev_get_uclass_priv(dev);
|
|
|
|
int ret;
|
2014-02-27 20:26:19 +00:00
|
|
|
|
2016-01-19 02:52:25 +00:00
|
|
|
ret = sandbox_sdl_init_display(plat->xres, plat->yres, plat->bpix);
|
|
|
|
if (ret) {
|
2014-02-27 20:26:19 +00:00
|
|
|
puts("LCD init failed\n");
|
2016-01-19 02:52:25 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
uc_priv->xsize = plat->xres;
|
|
|
|
uc_priv->ysize = plat->yres;
|
|
|
|
uc_priv->bpix = plat->bpix;
|
|
|
|
uc_priv->rot = plat->rot;
|
2016-01-15 01:10:49 +00:00
|
|
|
uc_priv->vidconsole_drv_name = plat->vidconsole_drv_name;
|
|
|
|
uc_priv->font_size = plat->font_size;
|
2016-01-19 02:52:25 +00:00
|
|
|
|
|
|
|
return 0;
|
2014-02-27 20:26:19 +00:00
|
|
|
}
|
|
|
|
|
2016-01-19 02:52:25 +00:00
|
|
|
static int sandbox_sdl_bind(struct udevice *dev)
|
2014-02-27 20:26:19 +00:00
|
|
|
{
|
2016-01-19 02:52:25 +00:00
|
|
|
struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev);
|
|
|
|
struct sandbox_sdl_plat *plat = dev_get_platdata(dev);
|
2014-02-27 20:26:19 +00:00
|
|
|
const void *blob = gd->fdt_blob;
|
2017-01-17 23:52:55 +00:00
|
|
|
int node = dev_of_offset(dev);
|
2014-02-27 20:26:19 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
2016-01-19 02:52:25 +00:00
|
|
|
plat->xres = fdtdec_get_int(blob, node, "xres", LCD_MAX_WIDTH);
|
|
|
|
plat->yres = fdtdec_get_int(blob, node, "yres", LCD_MAX_HEIGHT);
|
|
|
|
plat->bpix = VIDEO_BPP16;
|
|
|
|
uc_plat->size = plat->xres * plat->yres * (1 << plat->bpix) / 8;
|
|
|
|
debug("%s: Frame buffer size %x\n", __func__, uc_plat->size);
|
2014-02-27 20:26:19 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2016-01-19 02:52:25 +00:00
|
|
|
|
|
|
|
static const struct udevice_id sandbox_sdl_ids[] = {
|
|
|
|
{ .compatible = "sandbox,lcd-sdl" },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(sdl_sandbox) = {
|
|
|
|
.name = "sdl_sandbox",
|
|
|
|
.id = UCLASS_VIDEO,
|
|
|
|
.of_match = sandbox_sdl_ids,
|
|
|
|
.bind = sandbox_sdl_bind,
|
|
|
|
.probe = sandbox_sdl_probe,
|
|
|
|
.platdata_auto_alloc_size = sizeof(struct sandbox_sdl_plat),
|
|
|
|
};
|