]> git.ipfire.org Git - people/ms/u-boot.git/blame - drivers/video/sandbox_sdl.c
rockchip: video: Flush the cache when the display is updated
[people/ms/u-boot.git] / drivers / video / sandbox_sdl.c
CommitLineData
7d95f2a3
SG
1/*
2 * Copyright (c) 2013 Google, Inc
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
3ade5bc4 8#include <dm.h>
7d95f2a3 9#include <fdtdec.h>
3ade5bc4 10#include <video.h>
7d95f2a3
SG
11#include <asm/sdl.h>
12#include <asm/u-boot-sandbox.h>
3ade5bc4 13#include <dm/test.h>
7d95f2a3
SG
14
15DECLARE_GLOBAL_DATA_PTR;
16
17enum {
3ade5bc4 18 /* Default LCD size we support */
7d95f2a3
SG
19 LCD_MAX_WIDTH = 1366,
20 LCD_MAX_HEIGHT = 768,
7d95f2a3
SG
21};
22
3ade5bc4 23static int sandbox_sdl_probe(struct udevice *dev)
7d95f2a3 24{
3ade5bc4
SG
25 struct sandbox_sdl_plat *plat = dev_get_platdata(dev);
26 struct video_priv *uc_priv = dev_get_uclass_priv(dev);
27 int ret;
7d95f2a3 28
3ade5bc4
SG
29 ret = sandbox_sdl_init_display(plat->xres, plat->yres, plat->bpix);
30 if (ret) {
7d95f2a3 31 puts("LCD init failed\n");
3ade5bc4
SG
32 return ret;
33 }
34 uc_priv->xsize = plat->xres;
35 uc_priv->ysize = plat->yres;
36 uc_priv->bpix = plat->bpix;
37 uc_priv->rot = plat->rot;
8de536c2
SG
38 uc_priv->vidconsole_drv_name = plat->vidconsole_drv_name;
39 uc_priv->font_size = plat->font_size;
3ade5bc4
SG
40
41 return 0;
7d95f2a3
SG
42}
43
3ade5bc4 44static int sandbox_sdl_bind(struct udevice *dev)
7d95f2a3 45{
3ade5bc4
SG
46 struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev);
47 struct sandbox_sdl_plat *plat = dev_get_platdata(dev);
7d95f2a3 48 const void *blob = gd->fdt_blob;
3ade5bc4 49 int node = dev->of_offset;
7d95f2a3
SG
50 int ret = 0;
51
3ade5bc4
SG
52 plat->xres = fdtdec_get_int(blob, node, "xres", LCD_MAX_WIDTH);
53 plat->yres = fdtdec_get_int(blob, node, "yres", LCD_MAX_HEIGHT);
54 plat->bpix = VIDEO_BPP16;
55 uc_plat->size = plat->xres * plat->yres * (1 << plat->bpix) / 8;
56 debug("%s: Frame buffer size %x\n", __func__, uc_plat->size);
7d95f2a3
SG
57
58 return ret;
59}
3ade5bc4
SG
60
61static const struct udevice_id sandbox_sdl_ids[] = {
62 { .compatible = "sandbox,lcd-sdl" },
63 { }
64};
65
66U_BOOT_DRIVER(sdl_sandbox) = {
67 .name = "sdl_sandbox",
68 .id = UCLASS_VIDEO,
69 .of_match = sandbox_sdl_ids,
70 .bind = sandbox_sdl_bind,
71 .probe = sandbox_sdl_probe,
72 .platdata_auto_alloc_size = sizeof(struct sandbox_sdl_plat),
73};