[coreboot-gerrit] Change in libgfxinit[master]: [WIP] Add `defaultfb` for Linux fb setup
Nico Huber (Code Review)
gerrit at coreboot.org
Tue Jan 23 15:14:54 CET 2018
Nico Huber has uploaded this change for review. ( https://review.coreboot.org/23393
Change subject: [WIP] Add `defaultfb` for Linux fb setup
......................................................................
[WIP] Add `defaultfb` for Linux fb setup
Change-Id: Ieb8ef8bcd32b5d0d1796f44f126d5f3a90477433
Signed-off-by: Nico Huber <nico.huber at secunet.com>
---
M .gitignore
M Makefile
M Makefile.inc
A defaultfb/Makefile
A defaultfb/Makefile.inc
A defaultfb/default_fb.adb
A defaultfb/default_fb.ads
A defaultfb/default_fb_main.adb
A defaultfb/defaultfb.c
9 files changed, 232 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/93/23393/1
diff --git a/.gitignore b/.gitignore
index 69f6818..ad8c8a0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,10 @@
/dest/
/*.gpr
/.config
+/defaultfb/.defaultfb.*o.cmd
+/defaultfb/.tmp_versions/
+/defaultfb/Module.symvers
+/defaultfb/defaultfb.*o
+/defaultfb/defaultfb.mod.*
+/defaultfb/modules.order
+
diff --git a/Makefile b/Makefile
index 008b2b3..369e0d0 100644
--- a/Makefile
+++ b/Makefile
@@ -6,11 +6,17 @@
GFXINIT_TEST := y
endif
+ifeq ($(MAKECMDGOALS),default_fb)
+prefixed-name := default_fb
+link-type := program
+DEFAULT_FB := y
+endif
+
gfxinit-deplibs := libhw
libhw-dir ?= ../libhwbase/dest
include $(libhw-dir)/Makefile
-gfx_test: $(binary)
+gfx_test default_fb: $(binary)
-.PHONY: gfx_test
+.PHONY: gfx_test default_fb
diff --git a/Makefile.inc b/Makefile.inc
index 322ee66..df8b890 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -1,3 +1,4 @@
subdirs-y += common
+subdirs-$(DEFAULT_FB) += defaultfb
subdirs-$(GFXINIT_TEST) += gfxtest
diff --git a/defaultfb/Makefile b/defaultfb/Makefile
new file mode 100644
index 0000000..16d3dc9
--- /dev/null
+++ b/defaultfb/Makefile
@@ -0,0 +1,16 @@
+MODULE_NAME = defaultfb
+MODULE_FILE = $(MODULE_NAME).ko
+obj-m = $(MODULE_NAME).o
+
+KERNEL_SOURCE ?= /lib/modules/$(shell uname -r)/build/
+
+all: $(MODULE_FILE)
+
+$(MODULE_FILE): $(MODULE_NAME).c
+ $(MAKE) -C$(KERNEL_SOURCE) SUBDIRS=$(CURDIR) modules
+
+clean:
+ $(MAKE) -C$(KERNEL_SOURCE) SUBDIRS=$(CURDIR) clean
+
+.PHONY: all clean
+
diff --git a/defaultfb/Makefile.inc b/defaultfb/Makefile.inc
new file mode 100644
index 0000000..a526d97
--- /dev/null
+++ b/defaultfb/Makefile.inc
@@ -0,0 +1,4 @@
+gfxinit-y += default_fb.adb
+gfxinit-y += default_fb.ads
+
+gfxinit-main-y = default_fb_main.adb
diff --git a/defaultfb/default_fb.adb b/defaultfb/default_fb.adb
new file mode 100644
index 0000000..0989881
--- /dev/null
+++ b/defaultfb/default_fb.adb
@@ -0,0 +1,109 @@
+with Ada.Command_Line;
+with Interfaces.C;
+
+with HW;
+with HW.Debug;
+with HW.PCI;
+with HW.PCI.Dev;
+with HW.GFX;
+with HW.GFX.GMA;
+with HW.GFX.GMA.Display_Probing;
+
+use HW;
+use HW.GFX;
+
+package body Default_FB
+is
+ pragma Disable_Atomic_Synchronization;
+
+ package Dev is new HW.PCI.Dev (HW.PCI.Address'(0, 2, 0));
+
+ procedure Main
+ is
+ use type HW.GFX.GMA.Port_Type;
+ use type Interfaces.C.int;
+ use type HW.Word32;
+ use type HW.Int32;
+
+ Pipes : HW.GFX.GMA.Pipe_Configs;
+ Width : Width_Type;
+ Height : Height_Type;
+ Base : Word32;
+
+ Initialized, Success : Boolean;
+
+ function iopl (level : Interfaces.C.int) return Interfaces.C.int;
+ pragma Import (C, iopl, "iopl");
+ begin
+ if Ada.Command_Line.Argument_Count >= 1 then
+ Width := Width_Type'Value (Ada.Command_Line.Argument (1));
+ if Ada.Command_Line.Argument_Count >= 2 then
+ Height := Height_Type'Value (Ada.Command_Line.Argument (2));
+ else
+ Height := Height_Type (Width);
+ end if;
+ else
+ Width := 1440;
+ Height := 900;
+ end if;
+
+ if iopl (3) /= 0 then
+ Debug.Put_Line ("Failed to change i/o privilege level.");
+ return;
+ end if;
+
+ Dev.Initialize (Initialized);
+ if not Initialized then
+ Debug.Put_Line ("Failed to map PCI config.");
+ return;
+ end if;
+ Dev.Read32 (Base, PCI.Base_Address (PCI.Res2));
+ Base := Base and PCI.Base_Address_Mem_Mask;
+
+ HW.GFX.GMA.Initialize
+ (Clean_State => True,
+ Success => Initialized);
+
+ if Initialized then
+ HW.GFX.GMA.Display_Probing.Scan_Ports (Pipes);
+
+ Initialized := False;
+ for Pipe in HW.GFX.GMA.Pipe_Index loop
+ if Pipes (Pipe).Port /= HW.GFX.GMA.Disabled then
+ Pipes (Pipe).Framebuffer :=
+ (Width => Width,
+ Height => Height,
+ Start_X => 0,
+ Start_Y => 0,
+ BPC => 8,
+ Stride => Div_Round_Up (Width, 16) * 16,
+ V_Stride => Height,
+ Tiling => Linear,
+ Rotation => No_Rotation,
+ Offset => 16#0000_0000#);
+ HW.GFX.GMA.Setup_Default_FB
+ (FB => Pipes (Pipe).Framebuffer,
+ Clear => False,
+ Success => Success);
+ if not Success then
+ Pipes (Pipe).Port := GMA.Disabled;
+ else
+ Initialized := True;
+ end if;
+ end if;
+ end loop;
+ end if;
+
+ if Initialized then
+ HW.GFX.GMA.Update_Outputs (Pipes);
+ Debug.Put ("base=");
+ Debug.Put_Word32 (Base);
+ Debug.Put (" width=");
+ Debug.Put_Int32 (Width);
+ Debug.Put (" height=");
+ Debug.Put_Int32 (Height);
+ Debug.New_Line;
+ end if;
+ end Main;
+
+end Default_FB;
diff --git a/defaultfb/default_fb.ads b/defaultfb/default_fb.ads
new file mode 100644
index 0000000..0faa6e0
--- /dev/null
+++ b/defaultfb/default_fb.ads
@@ -0,0 +1,4 @@
+package Default_FB
+is
+ procedure Main;
+end Default_FB;
diff --git a/defaultfb/default_fb_main.adb b/defaultfb/default_fb_main.adb
new file mode 100644
index 0000000..a1f130f
--- /dev/null
+++ b/defaultfb/default_fb_main.adb
@@ -0,0 +1,7 @@
+with Default_FB;
+
+procedure Default_FB_Main
+is
+begin
+ Default_FB.Main;
+end Default_FB_Main;
diff --git a/defaultfb/defaultfb.c b/defaultfb/defaultfb.c
new file mode 100644
index 0000000..d3d6235
--- /dev/null
+++ b/defaultfb/defaultfb.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2018 secunet Security Networks AG
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_data/simplefb.h>
+#include <linux/platform_device.h>
+
+static unsigned int width = 1440;
+static unsigned int height = 900;
+module_param(width, uint, 0);
+module_param(height, uint, 0);
+
+static unsigned long base = 0;
+module_param(base, ulong, 0);
+
+static struct platform_device *defaultfb_device;
+
+static int __init defaultfb_init(void)
+{
+ struct simplefb_platform_data mode;
+ struct resource res;
+ unsigned long len;
+
+ if (!base)
+ return -ENXIO;
+
+ mode.format = "a8r8g8b8";
+ mode.width = width;
+ mode.height = height;
+ mode.stride = ALIGN(width, 64);
+
+ /* calculate framebuffer length */
+ len = mode.height * mode.stride;
+
+ /* setup i/o resource */
+ memset(&res, 0, sizeof(res));
+ res.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+ res.name = "DEFAULTFB";
+ res.start = base;
+ res.end = base + len;
+ if (res.end < res.start) {
+ printk(KERN_WARNING "defaultfb: fb is too large\n");
+ return -EINVAL;
+ }
+
+ defaultfb_device = platform_device_register_resndata(
+ NULL, "simple-framebuffer", 0, &res, 1, &mode, sizeof(mode));
+
+ if (IS_ERR(defaultfb_device))
+ return PTR_ERR(defaultfb_device);
+
+ return 0;
+}
+
+module_init(defaultfb_init);
+
+static void __exit defaultfb_exit(void)
+{
+ platform_device_unregister(defaultfb_device);
+}
+
+module_exit(defaultfb_exit);
+
+MODULE_LICENSE("GPL");
--
To view, visit https://review.coreboot.org/23393
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieb8ef8bcd32b5d0d1796f44f126d5f3a90477433
Gerrit-Change-Number: 23393
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h at gmx.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180123/d0b0480e/attachment-0001.html>
More information about the coreboot-gerrit
mailing list