Files
LibreELEC.tv/projects/Amlogic/initramfs/platform_init
2018-05-29 09:23:01 +02:00

112 lines
3.6 KiB
Bash
Executable File

#!/bin/sh
################################################################################
# This file is part of LibreELEC - https://libreelec.tv
# Copyright (C) 2017-present Team LibreELEC
#
# LibreELEC 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.
#
# LibreELEC 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.
#
# You should have received a copy of the GNU General Public License
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
display_mode=$(cat /sys/class/display/mode)
for arg in $(cat /proc/cmdline); do
case ${arg} in
bootfrom*)
bootfromext=1
;;
BOOT_IMAGE=*)
BOOT_IMAGE=${arg#*=}
;;
boot=*)
boot=${arg#*=}
;;
disk=*)
disk=${arg#*=}
;;
hdmimode=*)
hdmimode=${arg#*=}
;;
esac
done
# Add information where to run LibreELEC from
if [ -z "$BOOT_IMAGE" -o -z "$boot" -o -z "$disk" ]; then
cmdline=$(cat /proc/cmdline)
if [ -n "$bootfromext" ]; then
cmdline="$cmdline BOOT_IMAGE=kernel.img boot=LABEL=@BOOT_LABEL@ disk=LABEL=@DISK_LABEL@"
else
cmdline="$cmdline BOOT_IMAGE=/dev/boot boot=/dev/system disk=/dev/data"
fi
echo "$cmdline" > /proc/cmdline
fi
# Set colorspace to avoid no HDMI signal with non-4K output modes
echo 422,8bit > /sys/class/amhdmitx/amhdmitx0/attr
# Enable HDMI output if cable is connected and not already enabled by u-boot
if [ "$(cat /sys/class/amhdmitx/amhdmitx0/hpd_state)" != "0" ] && [ "$display_mode" != "$hdmimode" ]; then
echo "$hdmimode" > /sys/class/display/mode
display_mode="$hdmimode"
fi
# Set framebuffer geometry to match the resolution
case $display_mode in
480*) X=720 Y=480 ;;
576*) X=720 Y=576 ;;
720p*) X=1280 Y=720 ;;
*) X=1920 Y=1080 ;;
esac
fbset -fb /dev/fb0 -g $X $Y 1920 2160 32
fbset -fb /dev/fb1 -g 32 32 32 32 32
echo 0 > /sys/class/graphics/fb0/free_scale
echo 0 > /sys/class/graphics/fb1/free_scale
echo 1 > /sys/class/video/disable_video
# Enable scaling for 4K output
case $display_mode in
4k*|smpte*|2160*)
echo 0 0 1919 1079 > /sys/class/graphics/fb0/free_scale_axis
echo 0 0 3839 2159 > /sys/class/graphics/fb0/window_axis
echo 1920 > /sys/class/graphics/fb0/scale_width
echo 1080 > /sys/class/graphics/fb0/scale_height
echo 0x10001 > /sys/class/graphics/fb0/free_scale
;;
esac
# Include deinterlacer into default VFM map
echo rm default > /sys/class/vfm/map
echo add default decoder ppmgr deinterlace amvideo > /sys/class/vfm/map
# Enable framebuffer device
echo 0 > /sys/class/graphics/fb0/blank
# Blank fb1 to prevent static noise
echo 1 > /sys/class/graphics/fb1/blank
# set smp_affinity
# Binary Hex
# CPU 0 0001 1
# CPU 1 0010 2
# CPU 2 0100 4
# CPU 3 1000 8
echo 2 > /proc/irq/231/smp_affinity # hdmi_aocec
echo 4 > /proc/irq/63/smp_affinity # dwc_otg, dwc_otg_hcd:usb1
echo 8 > /proc/irq/62/smp_affinity # dwc_otg, dwc_otg_hcd:usb2, dwc_otg_pcd
# DEC_CONTROL_FLAG_DISABLE_FAST_POC
echo 4 > /sys/module/amvdec_h264/parameters/dec_control
echo 1 > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy