Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kodi/Intel: Various improvements from fritsch #573

Merged
merged 4 commits into from Aug 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/mediacenter/kodi/config/appliance.xml
Expand Up @@ -17,6 +17,9 @@
<setting id="videoscreen.screen">
<visible>false</visible>
</setting>
<setting id="videoscreen.limitedrange">
<level>1</level>
</setting>
</group>
<group id="3">
<setting id="videoscreen.noofbuffers">
Expand Down
@@ -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

7 changes: 7 additions & 0 deletions 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
16 changes: 16 additions & 0 deletions 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
@@ -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
@@ -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