Merge pull request #573 from MilhouseVH/fritsch4k

kodi/Intel: Various improvements from fritsch
This commit is contained in:
Christian Hewitt 2016-08-17 01:40:39 +04:00 committed by GitHub
commit 949a8350e2
6 changed files with 136 additions and 0 deletions

View File

@ -17,6 +17,9 @@
<setting id="videoscreen.screen"> <setting id="videoscreen.screen">
<visible>false</visible> <visible>false</visible>
</setting> </setting>
<setting id="videoscreen.limitedrange">
<level>1</level>
</setting>
</group> </group>
<group id="3"> <group id="3">
<setting id="videoscreen.noofbuffers"> <setting id="videoscreen.noofbuffers">

View File

@ -0,0 +1,83 @@
From b2db330176ca1115ae9a4bc31af082b80b87ecdb Mon Sep 17 00:00:00 2001
From: MilhouseVH <milhouseVH.github@nmacleod.com>
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<AVCodecID, std::string> &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<AVCodecID, std::string> &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

View File

@ -0,0 +1,7 @@
Section "Device"
Identifier "Device0"
Driver "intel"
VendorName "INTEL Corporation"
Option "TripleBuffer" "false"
Option "TearFree" "false"
EndSection

View File

@ -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

View File

@ -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

View File

@ -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