diff mbox series

[28/33] sandbox: Support changing the LCD colour depth

Message ID 20200112120216.28.I6e1d242c53cbe76b041651299cf5e971cc7fc7e8@changeid
State Accepted
Commit a466db5adb58e486fbd8ae63536b03a70d69f68d
Headers show
Series sandbox: Move to SDL2 | expand

Commit Message

Simon Glass Jan. 12, 2020, 7:06 p.m. UTC
Add a new device-tree property to control the colour depth. At present we
support 16bpp and 32bpp.

While we are here, update the code to use livetree.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 arch/sandbox/dts/sandbox.dtsi                 | 1 +
 doc/device-tree-bindings/video/sandbox-fb.txt | 6 +++++-
 drivers/video/sandbox_sdl.c                   | 8 +++-----
 3 files changed, 9 insertions(+), 6 deletions(-)

Comments

Anatolij Gustschin Jan. 12, 2020, 8:15 p.m. UTC | #1
On Sun, 12 Jan 2020 12:06:19 -0700
Simon Glass sjg at chromium.org wrote:

> Add a new device-tree property to control the colour depth. At present we
> support 16bpp and 32bpp.
> 
> While we are here, update the code to use livetree.
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>

Reviewed-by: Anatolij Gustschin <agust at denx.de>

--
Anatolij
diff mbox series

Patch

diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi
index 7bf144f532..7cd56c14f2 100644
--- a/arch/sandbox/dts/sandbox.dtsi
+++ b/arch/sandbox/dts/sandbox.dtsi
@@ -83,6 +83,7 @@ 
 		compatible = "sandbox,lcd-sdl";
 		xres = <1366>;
 		yres = <768>;
+		log2-depth = <5>;
 	};
 
 	leds {
diff --git a/doc/device-tree-bindings/video/sandbox-fb.txt b/doc/device-tree-bindings/video/sandbox-fb.txt
index eb91b30e3f..230d25c23b 100644
--- a/doc/device-tree-bindings/video/sandbox-fb.txt
+++ b/doc/device-tree-bindings/video/sandbox-fb.txt
@@ -2,7 +2,10 @@  Sandbox LCD
 ===========
 
 This uses the displaymode.txt binding except that only xres and yres are
-required properties.
+required properties. Also an additional optional property is defined:
+
+log2-depth: Log base 2 of the U-Boot display buffer depth (4=16bpp, 5=32bpp).
+	If not provided, a value of 4 is used.
 
 Example:
 
@@ -10,4 +13,5 @@  Example:
 		compatible = "sandbox,lcd-sdl";
 		xres = <800>;
 		yres = <600>;
+		log2-depth = <5>;
 	};
diff --git a/drivers/video/sandbox_sdl.c b/drivers/video/sandbox_sdl.c
index d1272d0918..1196e6c671 100644
--- a/drivers/video/sandbox_sdl.c
+++ b/drivers/video/sandbox_sdl.c
@@ -47,13 +47,11 @@  static int sandbox_sdl_bind(struct udevice *dev)
 {
 	struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev);
 	struct sandbox_sdl_plat *plat = dev_get_platdata(dev);
-	const void *blob = gd->fdt_blob;
-	int node = dev_of_offset(dev);
 	int ret = 0;
 
-	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;
+	plat->xres = dev_read_u32_default(dev, "xres", LCD_MAX_WIDTH);
+	plat->yres = dev_read_u32_default(dev, "yres", LCD_MAX_HEIGHT);
+	plat->bpix = dev_read_u32_default(dev, "log2-depth", VIDEO_BPP16);
 	uc_plat->size = plat->xres * plat->yres * (1 << plat->bpix) / 8;
 	debug("%s: Frame buffer size %x\n", __func__, uc_plat->size);