From ce0e76e1f5dbcc9d1650bc436638ad67dc6a5b01 Mon Sep 17 00:00:00 2001 From: fritsch Date: Sat, 13 Aug 2016 08:54:12 +0100 Subject: [PATCH 1/4] Intel: Implement Passthrough-Range --- .../filesystem/usr/bin/intel-fullrange.sh | 16 ++++++++++++++++ .../system/intel-fullrange-resume.service | 13 +++++++++++++ .../lib/systemd/system/intel-fullrange.service | 14 ++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 projects/Generic/filesystem/usr/bin/intel-fullrange.sh create mode 100644 projects/Generic/filesystem/usr/lib/systemd/system/intel-fullrange-resume.service create mode 100644 projects/Generic/filesystem/usr/lib/systemd/system/intel-fullrange.service diff --git a/projects/Generic/filesystem/usr/bin/intel-fullrange.sh b/projects/Generic/filesystem/usr/bin/intel-fullrange.sh new file mode 100644 index 0000000000..2b1be600dd --- /dev/null +++ b/projects/Generic/filesystem/usr/bin/intel-fullrange.sh @@ -0,0 +1,16 @@ +#!/bin/sh +FB_TYPE="$(grep '^0 ' /proc/fb | sed 's/[^[:space:]] //')" + +if [ "$FB_TYPE" == "inteldrmfb" ]; then + OUTPUT=`/usr/bin/xrandr -display :0 -q | sed '/ connected/!d;s/ .*//;q'` + for out in $OUTPUT ; do + # Hack - something is not yet fully right + /usr/bin/xrandr -display :0 --output $out --set "Broadcast RGB" "Full" + /usr/bin/xrandr -display :0 --output $out --set "Broadcast RGB" "Video 16:235 pass-through" + # Seems there is a little race somewhere on some outputs + # Turn the display shortly off and on again + if [ -e "/storage/.config/forcedisplay" ]; then + /usr/bin/xrandr -display :0 --output $out --off ; /usr/bin/xrandr -display :0 --output $out --auto + fi + done +fi diff --git a/projects/Generic/filesystem/usr/lib/systemd/system/intel-fullrange-resume.service b/projects/Generic/filesystem/usr/lib/systemd/system/intel-fullrange-resume.service new file mode 100644 index 0000000000..b10a82ee79 --- /dev/null +++ b/projects/Generic/filesystem/usr/lib/systemd/system/intel-fullrange-resume.service @@ -0,0 +1,13 @@ +[Unit] +Description=Restore full range after suspend +Before=sleep.target +StopWhenUnneeded=yes + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/bin/true +ExecStop=-/bin/sh "/usr/bin/intel-fullrange.sh" + +[Install] +WantedBy=sleep.target diff --git a/projects/Generic/filesystem/usr/lib/systemd/system/intel-fullrange.service b/projects/Generic/filesystem/usr/lib/systemd/system/intel-fullrange.service new file mode 100644 index 0000000000..f1dab89870 --- /dev/null +++ b/projects/Generic/filesystem/usr/lib/systemd/system/intel-fullrange.service @@ -0,0 +1,14 @@ +[Unit] +Description=intel switch to full range +Before=kodi.service +After=graphical.target + +[Service] +Type=oneshot +Environment=DISPLAY=:0.0 +ExecStart=-/bin/sh "/usr/bin/intel-fullrange.sh" +StandardError=null +RemainAfterExit=yes + +[Install] +WantedBy=kodi.target From 12e3c05d0ded9fadc8ed0abc5ba14d289437b525 Mon Sep 17 00:00:00 2001 From: fritsch Date: Sat, 13 Aug 2016 08:54:12 +0100 Subject: [PATCH 2/4] xf86-video-intel: Explicitely disable TearFree and TripleBuffer --- projects/Generic/filesystem/etc/X11/xorg-i915.conf | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 projects/Generic/filesystem/etc/X11/xorg-i915.conf diff --git a/projects/Generic/filesystem/etc/X11/xorg-i915.conf b/projects/Generic/filesystem/etc/X11/xorg-i915.conf new file mode 100644 index 0000000000..f4f70ae255 --- /dev/null +++ b/projects/Generic/filesystem/etc/X11/xorg-i915.conf @@ -0,0 +1,7 @@ +Section "Device" + Identifier "Device0" + Driver "intel" + VendorName "INTEL Corporation" + Option "TripleBuffer" "false" + Option "TearFree" "false" +EndSection From fd880594fb56717323e249bdd61d1886837501c9 Mon Sep 17 00:00:00 2001 From: MilhouseVH Date: Sat, 13 Aug 2016 08:54:12 +0100 Subject: [PATCH 3/4] kodi: Detect intel gpus and use limited range by default --- .../kodi-999.99-detect-intel-gpus.patch | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 packages/mediacenter/kodi/patches/kodi-999.99-detect-intel-gpus.patch diff --git a/packages/mediacenter/kodi/patches/kodi-999.99-detect-intel-gpus.patch b/packages/mediacenter/kodi/patches/kodi-999.99-detect-intel-gpus.patch new file mode 100644 index 0000000000..fc1ebf792c --- /dev/null +++ b/packages/mediacenter/kodi/patches/kodi-999.99-detect-intel-gpus.patch @@ -0,0 +1,83 @@ +From b2db330176ca1115ae9a4bc31af082b80b87ecdb Mon Sep 17 00:00:00 2001 +From: MilhouseVH +Date: Thu, 11 Aug 2016 07:32:48 +0100 +Subject: [PATCH] LibreELEC: Detect intel gpus and use limited range by default + +--- + xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.cpp | 11 +++++++++++ + xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h | 5 +++++ + xbmc/settings/Settings.cpp | 9 +++++++++ + 3 files changed, 25 insertions(+) + +diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.cpp +index e8071bd..83db224 100644 +--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.cpp ++++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.cpp +@@ -22,6 +22,8 @@ + #include "settings/Settings.h" + #include "settings/lib/Setting.h" + #include "windowing/WindowingFactory.h" ++#include "utils/SysfsUtils.h" ++#include "utils/StringUtils.h" + + bool CDVDVideoCodec::IsSettingVisible(const std::string &condition, const std::string &value, const CSetting *setting, void *data) + { +@@ -72,3 +74,12 @@ bool CDVDVideoCodec::IsCodecDisabled(const std::map &map + } + return false; // don't disable what we don't have + } ++ ++bool CDVDVideoCodec::IsIntel() ++{ ++ // check if we are running on intel hardware ++ std::string gpuvendor; ++ SysfsUtils::GetString("/proc/fb", gpuvendor); ++ ++ return StringUtils::EndsWith(gpuvendor, "inteldrmfb"); ++} +diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h +index a2da9de..cc8a574 100644 +--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h ++++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h +@@ -257,6 +257,11 @@ public: + static bool IsSettingVisible(const std::string &condition, const std::string &value, const CSetting *setting, void *data); + + /** ++ * Check if we are using an Intel GPU ++ */ ++ static bool IsIntel(); ++ ++ /** + * Interact with user settings so that user disabled codecs are disabled + */ + static bool IsCodecDisabled(const std::map &map, AVCodecID id); +diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp +index 0e429f3..7052391 100644 +--- a/xbmc/settings/Settings.cpp ++++ b/xbmc/settings/Settings.cpp +@@ -32,6 +32,7 @@ + #include "cores/AudioEngine/AEFactory.h" + #include "cores/playercorefactory/PlayerCoreFactory.h" + #include "cores/VideoPlayer/VideoRenderers/BaseRenderer.h" ++#include "cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h" + #include "filesystem/File.h" + #include "guilib/GraphicContext.h" + #include "guilib/GUIAudioManager.h" +@@ -911,6 +912,14 @@ void CSettings::InitializeDefaults() + + if (g_application.IsStandAlone()) + ((CSettingInt*)m_settingsManager->GetSetting(CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE))->SetDefault(POWERSTATE_SHUTDOWN); ++ ++#if ((defined(HAVE_LIBVA) || defined(HAVE_LIBVDPAU))) ++ bool isIntel = CDVDVideoCodec::IsIntel(); ++ // Intel driver is operating in passthrough mode so use limited range by default ++ ((CSettingBool*)GetSetting(CSettings::SETTING_VIDEOSCREEN_LIMITEDRANGE))->SetDefault(isIntel); ++ ((CSettingBool*)GetSetting(CSettings::SETTING_VIDEOPLAYER_USEVAAPI))->SetDefault(isIntel); ++ ((CSettingBool*)GetSetting(CSettings::SETTING_VIDEOPLAYER_USEVDPAU))->SetDefault(!isIntel); ++#endif + } + + void CSettings::InitializeOptionFillers() +-- +2.7.4 + From 8dc0cf382c4dcc5e3a118bd4540756042afeed10 Mon Sep 17 00:00:00 2001 From: MilhouseVH Date: Sat, 13 Aug 2016 08:54:12 +0100 Subject: [PATCH 4/4] kodi: Move limitedrange setting from Expert to Standard --- packages/mediacenter/kodi/config/appliance.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/mediacenter/kodi/config/appliance.xml b/packages/mediacenter/kodi/config/appliance.xml index a9f67d5b83..f076765f84 100644 --- a/packages/mediacenter/kodi/config/appliance.xml +++ b/packages/mediacenter/kodi/config/appliance.xml @@ -17,6 +17,9 @@ false + + 1 +