1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2013 Google, Inc
11 #include <asm/global_data.h>
13 #include <asm/state.h>
14 #include <asm/u-boot-sandbox.h>
17 DECLARE_GLOBAL_DATA_PTR;
20 /* Default LCD size we support */
25 static int sandbox_sdl_probe(struct udevice *dev)
27 struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
28 struct sandbox_sdl_plat *plat = dev_get_plat(dev);
29 struct video_priv *uc_priv = dev_get_uclass_priv(dev);
30 struct sandbox_state *state = state_get_current();
33 ret = sandbox_sdl_init_display(plat->xres, plat->yres, plat->bpix,
36 puts("LCD init failed\n");
39 uc_priv->xsize = plat->xres;
40 uc_priv->ysize = plat->yres;
41 uc_priv->bpix = plat->bpix;
42 uc_priv->rot = plat->rot;
43 uc_priv->vidconsole_drv_name = plat->vidconsole_drv_name;
44 uc_priv->font_size = plat->font_size;
45 if (IS_ENABLED(CONFIG_VIDEO_COPY))
46 uc_plat->copy_base = uc_plat->base - uc_plat->size / 2;
51 static void set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp)
53 struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
54 struct sandbox_sdl_plat *plat = dev_get_plat(dev);
58 uc_plat->size = plat->xres * plat->yres * (1 << plat->bpix) / 8;
60 /* Allow space for two buffers, the lower one being the copy buffer */
61 log_debug("Frame buffer size %x\n", uc_plat->size);
62 if (IS_ENABLED(CONFIG_VIDEO_COPY))
66 static int sandbox_sdl_bind(struct udevice *dev)
68 struct sandbox_sdl_plat *plat = dev_get_plat(dev);
69 enum video_log2_bpp l2bpp;
72 plat->xres = dev_read_u32_default(dev, "xres", LCD_MAX_WIDTH);
73 plat->yres = dev_read_u32_default(dev, "yres", LCD_MAX_HEIGHT);
74 l2bpp = dev_read_u32_default(dev, "log2-depth", VIDEO_BPP16);
75 plat->rot = dev_read_u32_default(dev, "rotate", 0);
82 static const struct udevice_id sandbox_sdl_ids[] = {
83 { .compatible = "sandbox,lcd-sdl" },
87 U_BOOT_DRIVER(sandbox_lcd_sdl) = {
88 .name = "sandbox_lcd_sdl",
90 .of_match = sandbox_sdl_ids,
91 .bind = sandbox_sdl_bind,
92 .probe = sandbox_sdl_probe,
93 .plat_auto = sizeof(struct sandbox_sdl_plat),