Skip to content

Commit

Permalink
Merge pull request #541 from drieschel/boot-resolution
Browse files Browse the repository at this point in the history
WeTek: Set the resolution more precisely at boot
  • Loading branch information
chewitt committed Jul 17, 2016
2 parents e8b2fae + ded8905 commit 0f8bbb6
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 11 deletions.
62 changes: 57 additions & 5 deletions projects/WeTek_Core/initramfs/platform_init
@@ -1,7 +1,7 @@
#!/bin/sh
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2014 Alex Deryskyba (alex@codesnake.com)
#
# OpenELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -17,7 +17,7 @@
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################

hdmimode=720p
hdmimode="720p"

# Parse command line arguments
for arg in $(cat /proc/cmdline); do
Expand Down Expand Up @@ -51,16 +51,68 @@ echo 0 > /sys/class/graphics/fb0/free_scale
# set initial video state
echo 1 > /sys/class/video/disable_video

# Set framebuffer geometry to match the resolution
# Set default resolution parameters
bpp=32;
xRes=1280;
yRes=720;

# Get max supported display resolution by hdmi device
maxRes=$(tail -n1 /sys/class/amhdmitx/amhdmitx0/disp_cap | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//');
if [ -z "$maxRes" ]; then
maxRes="$hdmimode";
fi
case "$maxRes" in
480*)
xRes=720; yRes=480;
;;
576*)
xRes=720; yRes=576;
;;
1080*)
xRes=1920; yRes=1080;
;;
4k2k*hz|2160p*)
xRes=3840; yRes=2160;
;;
4k2ksmpte|smpte24hz)
xRes=4096; yRes=2160;
;;
esac
vXRes=$xRes;
vYRes=$(( $yRes * 2 ));

# Choose boot resolution by hdmimode param
case "$hdmimode" in
480*)
if [ "$vXRes" -ge 720 -a "$vYRes" -ge 960 ]; then
xRes=720; yRes=480;
fi
;;
576*)
if [ "$vXRes" -ge 720 -a "$vYRes" -ge 1152 ]; then
xRes=720; yRes=576;
fi
;;
720*)
fbset -fb /dev/fb0 -g 1280 720 1920 2160 32
if [ "$vXRes" -ge 1280 -a "$vYRes" -ge 1440 ]; then
xRes=1280; yRes=720;
fi
;;
1080*)
fbset -fb /dev/fb0 -g 1920 1080 1920 2160 32
if [ "$vXRes" -ge 1920 -a "$vYRes" -ge 2160 ]; then
xRes=1920; yRes=1080;
fi
;;
4k2k*hz|2160p*)
if [ "$vXRes" -ge 3840 -a "$vYRes" -ge 4320 ]; then
xRes=3840; yRes=2160;
fi
;;
esac

# Set framebuffer geometry to match the resolution
fbset -fb /dev/fb0 -g $xRes $yRes $vXRes $vYRes $bpp;

# Include deinterlacer into default VFM map
echo rm default > /sys/class/vfm/map
echo add default decoder ppmgr deinterlace amvideo > /sys/class/vfm/map
Expand Down
66 changes: 60 additions & 6 deletions projects/WeTek_Play/initramfs/platform_init
@@ -1,5 +1,4 @@
#!/bin/sh

################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2014 Alex Deryskyba (alex@codesnake.com)
Expand All @@ -18,7 +17,7 @@
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################

hdmimode=720p
hdmimode="720p"

# Parse command line arguments
for arg in $(cat /proc/cmdline); do
Expand All @@ -40,25 +39,80 @@ done

echo "$hdmimode" > /sys/class/display/mode

# Enable framebuffer device
# Enable first framebuffer
echo 0 > /sys/class/graphics/fb0/blank

# Disable second framebuffer
echo 1 > /sys/class/graphics/fb1/blank

# Disable framebuffer scaling
echo 0 > /sys/class/graphics/fb0/free_scale

# set initial video state
echo 1 > /sys/class/video/disable_video

# Set framebuffer geometry to match the resolution
# Set default resolution parameters
bpp=32;
xRes=1280;
yRes=720;

# Get max supported display resolution by hdmi device
maxRes=$(tail -n1 /sys/class/amhdmitx/amhdmitx0/disp_cap | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//');
if [ -z "$maxRes" ]; then
maxRes="$hdmimode";
fi
case "$maxRes" in
480*)
xRes=720; yRes=480;
;;
576*)
xRes=720; yRes=576;
;;
1080*)
xRes=1920; yRes=1080;
;;
4k2k*hz|2160p*)
xRes=3840; yRes=2160;
;;
4k2ksmpte|smpte24hz)
xRes=4096; yRes=2160;
;;
esac
vXRes=$xRes;
vYRes=$(( $yRes * 2 ));

# Choose boot resolution by hdmimode param
case "$hdmimode" in
480*)
if [ "$vXRes" -ge 720 -a "$vYRes" -ge 960 ]; then
xRes=720; yRes=480;
fi
;;
576*)
if [ "$vXRes" -ge 720 -a "$vYRes" -ge 1152 ]; then
xRes=720; yRes=576;
fi
;;
720*)
fbset -fb /dev/fb0 -g 1280 720 1920 2160 32
if [ "$vXRes" -ge 1280 -a "$vYRes" -ge 1440 ]; then
xRes=1280; yRes=720;
fi
;;
1080*)
fbset -fb /dev/fb0 -g 1920 1080 1920 2160 32
if [ "$vXRes" -ge 1920 -a "$vYRes" -ge 2160 ]; then
xRes=1920; yRes=1080;
fi
;;
4k2k*hz|2160p*)
if [ "$vXRes" -ge 3840 -a "$vYRes" -ge 4320 ]; then
xRes=3840; yRes=2160;
fi
;;
esac

# Set framebuffer geometry to match the resolution
fbset -fb /dev/fb0 -g $xRes $yRes $vXRes $vYRes $bpp;

# Include deinterlacer into default VFM map
echo rm default > /sys/class/vfm/map
echo add default decoder ppmgr deinterlace amvideo > /sys/class/vfm/map
Expand Down

0 comments on commit 0f8bbb6

Please sign in to comment.