Radix cross Linux

Radix Linux distribution for embedded systems.

637 Commits   4 Branches   3 Tags
author: Andrey V.Kosteltsev <kx@radix.pro> 2016-09-14 11:48:50 +0000 committer: Andrey V.Kosteltsev <kx@radix.pro> 2016-09-14 11:48:50 +0000 commit: bda3b3d05d926e61f65b529b5b64634d7830691c parent: ce46e4efe852387ff7cc473eadd82965bbf2c03c
Commit Summary:
Set up FrameBuffer during system init for Amlogic boards
Diffstat:
5 files changed, 122 insertions, 2 deletions
diff --git a/base/radix-system/Makefile b/base/radix-system/Makefile
index cdbc419b1..ed59c0c85 100644
--- a/base/radix-system/Makefile
+++ b/base/radix-system/Makefile
@@ -25,6 +25,7 @@ include ../../build-system/constants.mk
 
 source_etc  = $(CURDIR)/etc
 modprobes   = $(CURDIR)/modprobe
+scripts     = $(CURDIR)/scripts
 
 
 PKG_GROUP = base
@@ -103,13 +104,17 @@ $(build):
 	 )
 	@chmod a+x $(SYSINIT_BIN_PKG)/etc/rc.d/rc.{local.new,local_shutdown.new,sysvinit.new}
 	# ======= Console Font config an modules config =======
-	@cp -a $(source_etc)/rc.d/rc.{font,gpm,keymap,modules} $(SYSINIT_BIN_PKG)/etc/rc.d
+	@cp -a $(source_etc)/rc.d/rc.{fbset,font,gpm,keymap,modules} $(SYSINIT_BIN_PKG)/etc/rc.d
 	@( cd $(SYSINIT_BIN_PKG)/etc/rc.d ; \
+	   mv rc.fbset    rc.fbset.new   ; \
 	   mv rc.font     rc.font.new    ; \
 	   mv rc.gpm      rc.gpm.new     ; \
 	   mv rc.keymap   rc.keymap.new  ; \
 	   mv rc.modules  rc.modules.new ; \
 	 )
+ifneq ($(filter $(HARDWARE),$(HARDWARE_M201) $(HARDWARE_MXQ)),)
+	@cat $(scripts)/rc.mesonfb >> $(SYSINIT_BIN_PKG)/etc/rc.d/rc.fbset.new
+endif
 ifneq ($(filter $(HARDWARE),$(HARDWARE_CB1X)),)
 	@echo "# Ethernet:"                    >> $(SYSINIT_BIN_PKG)/etc/rc.d/rc.modules.new
 	@echo "/sbin/modprobe sunxi_gmac"      >> $(SYSINIT_BIN_PKG)/etc/rc.d/rc.modules.new
@@ -146,7 +151,7 @@ endif
 ifneq ($(filter $(HARDWARE),$(HARDWARE_OMAP5UEVM)),)
 	@cat $(modprobes)/modprobe.$(HARDWARE) >> $(SYSINIT_BIN_PKG)/etc/rc.d/rc.modules.new
 endif
-	@chmod a+x $(SYSINIT_BIN_PKG)/etc/rc.d/rc.{font.new,gpm.new,keymap.new,modules.new}
+	@chmod a+x $(SYSINIT_BIN_PKG)/etc/rc.d/rc.{fbset.new,font.new,gpm.new,keymap.new,modules.new}
 	# ======= etc/inittab =======
 	@cat $(source_etc)/inittab.in | \
 	     sed 's,@NOCLEAR@,$(NOCLEAR_FIRST_TTY),'  > $(SYSINIT_BIN_PKG)/etc/inittab.new
diff --git a/base/radix-system/etc/rc.d/rc.M.in b/base/radix-system/etc/rc.d/rc.M.in
index 3d6cd23b4..18cc1020b 100644
--- a/base/radix-system/etc/rc.d/rc.M.in
+++ b/base/radix-system/etc/rc.d/rc.M.in
@@ -499,6 +499,11 @@ if [ -x /etc/rc.d/rc.sysvinit ]; then
   . /etc/rc.d/rc.sysvinit
 fi
 
+# Start the framebuffer setup procedure.
+if [ -x /etc/rc.d/rc.fbset ]; then
+  . /etc/rc.d/rc.fbset
+fi
+
 # Start the local setup procedure.
 if [ -x /etc/rc.d/rc.local ]; then
   . /etc/rc.d/rc.local
diff --git a/base/radix-system/etc/rc.d/rc.fbset b/base/radix-system/etc/rc.d/rc.fbset
new file mode 100644
index 000000000..c32425069
--- /dev/null
+++ b/base/radix-system/etc/rc.d/rc.fbset
@@ -0,0 +1,6 @@
+#!/bin/sh
+#
+# This setup default framebuffer mode.
+#
+# fbset(8)
+
diff --git a/base/radix-system/radix-system-pkg-install.sh b/base/radix-system/radix-system-pkg-install.sh
index 2214fb77a..5508d356e 100755
--- a/base/radix-system/radix-system-pkg-install.sh
+++ b/base/radix-system/radix-system-pkg-install.sh
@@ -62,6 +62,7 @@ post_install() {
   install_file etc/ld.so.conf.new
 
   # not fully finished stuff - depends on app/kbd, app/gpm, and kernel modules:
+  install_file etc/rc.d/rc.fbset.new
   install_file etc/rc.d/rc.font.new
   install_file etc/rc.d/rc.gpm.new
   install_file etc/rc.d/rc.keymap.new
diff --git a/base/radix-system/scripts/rc.mesonfb b/base/radix-system/scripts/rc.mesonfb
new file mode 100644
index 000000000..f92e9d9c2
--- /dev/null
+++ b/base/radix-system/scripts/rc.mesonfb
@@ -0,0 +1,124 @@
+#
+# rc.mesonfb - initial set up meson framebuffer
+#
+hdmimode=720p
+
+# Parse command line arguments
+for arg in $(cat /proc/cmdline); do
+  case $arg in
+    hdmimode=*)
+      hdmimode="${arg#*=}"
+      ;;
+  esac
+done
+
+outputmode=$hdmimode
+
+/bin/echo $outputmode > /sys/class/display/mode
+
+# Enable framebuffer device
+/bin/echo 0 > /sys/class/graphics/fb0/blank
+
+# Blank fb1 to prevent static noise
+/bin/echo 1 > /sys/class/graphics/fb1/blank
+
+# Disable framebuffer scaling
+/bin/echo 0 > /sys/class/graphics/fb0/free_scale
+/bin/echo 0 > /sys/class/graphics/fb1/free_scale
+
+
+/bin/echo 1 > /sys/class/graphics/fb0/freescale_mode
+
+case $outputmode in
+  480*)
+    /bin/echo 0 0 1279 719 > /sys/class/graphics/fb0/free_scale_axis
+    /bin/echo 0 0 1279 719 > /sys/class/graphics/fb0/window_axis
+    ;;
+
+  576*)
+    /bin/echo 0 0 1279 719 > /sys/class/graphics/fb0/free_scale_axis
+    /bin/echo 0 0 1279 719 > /sys/class/graphics/fb0/window_axis
+    ;;
+
+  720*)
+    /bin/echo 0 0 1279 719 > /sys/class/graphics/fb0/free_scale_axis
+    /bin/echo 0 0 1279 719 > /sys/class/graphics/fb0/window_axis
+    ;;
+
+  1080*)
+    /bin/echo 0 0 1919 1079 > /sys/class/graphics/fb0/free_scale_axis
+    /bin/echo 0 0 1919 1079 > /sys/class/graphics/fb0/window_axis
+    ;;
+
+  4k2k*)
+    /bin/echo 0 0 1919 1079 > /sys/class/graphics/fb0/free_scale_axis
+    /bin/echo 0 0 1919 1079 > /sys/class/graphics/fb0/window_axis
+    ;;
+
+  *)
+    # outputmode = 720p
+    /bin/echo 720p > /sys/class/display/mode  
+    /bin/echo 0 0 1279 719 > /sys/class/graphics/fb0/free_scale_axis
+    /bin/echo 0 0 1279 719 > /sys/class/graphics/fb0/window_axis
+    ;;
+esac
+
+
+# Set framebuffer geometry to match the resolution
+case "$hdmimode" in
+  720*)
+    /usr/sbin/fbset -fb /dev/fb0 -g 1280 720 1280 1440 32
+    ;;
+  1080*)
+    /usr/sbin/fbset -fb /dev/fb0 -g 1920 1080 1920 2160 32
+    ;;
+esac
+/usr/sbin/fbset -fb /dev/fb1 -g 32 32 32 32 32
+
+# Include deinterlacer into default VFM map
+/bin/echo rm default > /sys/class/vfm/map
+/bin/echo add default decoder ppmgr deinterlace amvideo > /sys/class/vfm/map
+
+################################################################
+#
+# If HDMI cable is connected during kernel start and the new
+# outputmode is equal to current hdmimode then the screen is
+# black.
+#
+# To wake up the monitor, we must reset outputmode.
+# Only in this case, the driver will wake the display up.
+#
+# Instead we will have to reconnect hdmi cable.
+#
+outputmode=$(cat /sys/class/display/mode)
+hpdstate=$(cat /sys/class/amhdmitx/amhdmitx0/hpd_state)
+
+if [ "$hpdstate" = "1" ]; then
+  # Blank fb0 to prevent static noise
+  /bin/echo 1 > /sys/class/graphics/fb0/blank
+    case $outputmode in
+      720*)
+        /bin/echo 1080p > /sys/class/display/mode
+        /bin/echo $outputmode > /sys/class/display/mode
+        ;;
+
+      1080*)
+        /bin/echo 720p > /sys/class/display/mode
+        /bin/echo $outputmode > /sys/class/display/mode
+        ;;
+      *)
+        # probably nobody asks 480cvbs
+        /bin/echo 480cvbs > /sys/class/display/mode
+        /bin/echo $outputmode > /sys/class/display/mode
+        ;;
+    esac
+  # Enable framebuffer device
+  /bin/echo 0 > /sys/class/graphics/fb0/blank
+fi
+#
+# End of HDMI cable reconnect trick.
+#
+################################################################
+
+echo 0x10001 > /sys/class/graphics/fb0/free_scale
+echo 0 > /sys/class/graphics/fb1/free_scale