kodi: Detect intel gpus and use limited range by default

This commit is contained in:
MilhouseVH 2016-08-13 08:54:12 +01:00
parent 12e3c05d0d
commit fd880594fb

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