Skip to content

Commit

Permalink
projects/WeTek_Hub: render GUI at 1080p for 4K output
Browse files Browse the repository at this point in the history
Issues with previous set of patches:
- at some 4K output resolutions GUI was rendered at 1080p and covered only 1/4 of screen due to not changed iWidth and iHeight parameters
- rendering GUI at 4K while playing high-bitrate 4K video caused stuttering

Changes introduced in this patch:
- rewrite platform_init to be aware of 4K resolutions passed by uboot in "hdmimode" parameter
- always set virtual framebuffer resolution to 1920x2160 (like Kodi does)
- remove Kodi patch to render GUI at 4K
- add Kodi patch (xbmc/xbmc#10332) to upscale GUI when screen resolution is 4K
  • Loading branch information
kszaq committed Aug 27, 2016
1 parent ed07827 commit 7f2ece2
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 156 deletions.
31 changes: 21 additions & 10 deletions projects/WeTek_Hub/initramfs/platform_init
Expand Up @@ -17,7 +17,7 @@
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################

hdmimode=720p
hdmimode=1080p60hz

# Parse command line arguments
for arg in $(cat /proc/cmdline); do
Expand All @@ -37,8 +37,6 @@ for arg in $(cat /proc/cmdline); do
esac
done

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

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

Expand All @@ -47,18 +45,31 @@ echo 1 > /sys/class/graphics/fb1/blank

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

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

# Set framebuffer geometry to match the resolution
case "$hdmimode" in
720*)
fbset -fb /dev/fb0 -g 1280 720 1920 2160 32
;;
1080*)
fbset -fb /dev/fb0 -g 1920 1080 1920 2160 32
;;
case $hdmimode 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

# Enable scaling for 4K output
case $hdmimode 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
Expand Down
@@ -0,0 +1,89 @@
From a348ef744e260f76e1e4e1299f9181ae40352eb5 Mon Sep 17 00:00:00 2001
From: kszaq <kszaquitto@gmail.com>
Date: Mon, 22 Aug 2016 06:55:00 +0200
Subject: [PATCH] EGLNativeTypeAmlogic: Enable GUI free_scale when framebuffer
size is less than output resolution

For 4K output Kodi renders GUI at 1080p and this results in GUI covering only 1/4 screen.
This patch enables hardware upscaling if output resolution is greater than rendered GUI
resolution.
---
xbmc/windowing/egl/EGLNativeTypeAmlogic.cpp | 33 ++++++++++++++++++++++++++---
xbmc/windowing/egl/EGLNativeTypeAmlogic.h | 2 ++
2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/xbmc/windowing/egl/EGLNativeTypeAmlogic.cpp b/xbmc/windowing/egl/EGLNativeTypeAmlogic.cpp
index 88cd385..3cbb604 100644
--- a/xbmc/windowing/egl/EGLNativeTypeAmlogic.cpp
+++ b/xbmc/windowing/egl/EGLNativeTypeAmlogic.cpp
@@ -133,6 +133,8 @@ bool CEGLNativeTypeAmlogic::GetNativeResolution(RESOLUTION_INFO *res) const

bool CEGLNativeTypeAmlogic::SetNativeResolution(const RESOLUTION_INFO &res)
{
+ bool result = false;
+
#if defined(_FBDEV_WINDOW_H_)
if (m_nativeWindow)
{
@@ -144,10 +146,12 @@ bool CEGLNativeTypeAmlogic::SetNativeResolution(const RESOLUTION_INFO &res)
// Don't set the same mode as current
std::string mode;
SysfsUtils::GetString("/sys/class/display/mode", mode);
- if (res.strId == mode)
- return false;
+ if (res.strId != mode)
+ result = SetDisplayResolution(res.strId.c_str());
+
+ DealWithScale(res);

- return SetDisplayResolution(res.strId.c_str());
+ return result;
}

bool CEGLNativeTypeAmlogic::ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutions)
@@ -220,6 +224,29 @@ void CEGLNativeTypeAmlogic::SetupVideoScaling(const char *mode)
SysfsUtils::SetInt("/sys/class/graphics/fb0/blank", 0);
}

+void CEGLNativeTypeAmlogic::DealWithScale(const RESOLUTION_INFO &res)
+{
+ if (res.iScreenWidth > res.iWidth && res.iScreenHeight > res.iHeight)
+ EnableFreeScale(res);
+ else
+ DisableFreeScale();
+}
+
+void CEGLNativeTypeAmlogic::EnableFreeScale(const RESOLUTION_INFO &res)
+{
+ char fsaxis_str[256] = {0};
+ sprintf(fsaxis_str, "0 0 %d %d", res.iWidth-1, res.iHeight-1);
+ char waxis_str[256] = {0};
+ sprintf(waxis_str, "0 0 %d %d", res.iScreenWidth-1, res.iScreenHeight-1);
+
+ SysfsUtils::SetInt("/sys/class/graphics/fb0/free_scale", 0);
+ SysfsUtils::SetString("/sys/class/graphics/fb0/free_scale_axis", fsaxis_str);
+ SysfsUtils::SetString("/sys/class/graphics/fb0/window_axis", waxis_str);
+ SysfsUtils::SetInt("/sys/class/graphics/fb0/scale_width", res.iWidth);
+ SysfsUtils::SetInt("/sys/class/graphics/fb0/scale_height", res.iHeight);
+ SysfsUtils::SetInt("/sys/class/graphics/fb0/free_scale", 0x10001);
+}
+
void CEGLNativeTypeAmlogic::DisableFreeScale()
{
// turn off frame buffer freescale
diff --git a/xbmc/windowing/egl/EGLNativeTypeAmlogic.h b/xbmc/windowing/egl/EGLNativeTypeAmlogic.h
index cfb33ca..96aa6f7 100644
--- a/xbmc/windowing/egl/EGLNativeTypeAmlogic.h
+++ b/xbmc/windowing/egl/EGLNativeTypeAmlogic.h
@@ -53,6 +53,8 @@ public:
protected:
bool SetDisplayResolution(const char *resolution);
void SetupVideoScaling(const char *mode);
+ void DealWithScale(const RESOLUTION_INFO &res);
+ void EnableFreeScale(const RESOLUTION_INFO &res);
void DisableFreeScale();

private:
--
1.8.3.1

This file was deleted.

13 changes: 13 additions & 0 deletions projects/WeTek_Hub/patches/kodi/0006-fix-resolution-fallback.patch
@@ -0,0 +1,13 @@
diff --git a/xbmc/windowing/egl/EGLNativeTypeAmlogic.cpp b/xbmc/windowing/egl/EGLNativeTypeAmlogic.cpp
index cad677a..ad7be0b 100644
--- a/xbmc/windowing/egl/EGLNativeTypeAmlogic.cpp
+++ b/xbmc/windowing/egl/EGLNativeTypeAmlogic.cpp
@@ -178,7 +178,7 @@ bool CEGLNativeTypeAmlogic::GetPreferredResolution(RESOLUTION_INFO *res) const
if (!GetNativeResolution(res))
{
// punt to 720p if we get nothing
- aml_mode_to_resolution("720p", res);
+ aml_mode_to_resolution("720p60hz", res);
}

return true;

This file was deleted.

0 comments on commit 7f2ece2

Please sign in to comment.