Skip to content

Commit

Permalink
kodi: add hacks and patches for Odroid XU3/XU4
Browse files Browse the repository at this point in the history
  • Loading branch information
chewitt committed Jun 30, 2022
1 parent fd7934b commit 2bb2a65
Show file tree
Hide file tree
Showing 6 changed files with 264 additions and 14 deletions.
@@ -1,7 +1,7 @@
From 8fd79203fde0a69c61b554e53bf95db84cc87ced Mon Sep 17 00:00:00 2001
From ba7571e105b75f4f303e02d5d0f76564e6c24bd3 Mon Sep 17 00:00:00 2001
From: chewitt <christianshewitt@gmail.com>
Date: Sat, 19 Sep 2020 16:25:19 +0000
Subject: [PATCH 1/5] HACK: skin.estuary: make event log conditional and move
Subject: [PATCH 1/6] HACK: skin.estuary: make event log conditional and move
LE settings

Move LE settings from the bottom grid to the top panel and hide Event Log
Expand Down
@@ -1,7 +1,7 @@
From 3a479ed9ba6310ee7787430a15cb519b736224e3 Mon Sep 17 00:00:00 2001
From 2f79a7de9b0a51455ab9b82e47f18ae1d91ef990 Mon Sep 17 00:00:00 2001
From: chewitt <christianshewitt@gmail.com>
Date: Wed, 28 Oct 2020 08:41:01 +0000
Subject: [PATCH 2/5] HACK: skin.estuary: make cpu/ram bars full width
Subject: [PATCH 2/6] HACK: skin.estuary: make cpu/ram bars full width

---
addons/skin.estuary/xml/SettingsSystemInfo.xml | 4 ++--
Expand Down
@@ -1,7 +1,7 @@
From 154ab44c40f71785de705aa9b5ea1bb963e30948 Mon Sep 17 00:00:00 2001
From 5b87c9b8d033dcd71b9a36f6e7e4b4736048f249 Mon Sep 17 00:00:00 2001
From: Christian Hewitt <christianshewitt@gmail.com>
Date: Sun, 20 Dec 2020 03:48:32 +0000
Subject: [PATCH 3/5] HACK: CPUInfo: Remove "#X:" prefixes on CPU readings to
Subject: [PATCH 3/6] HACK: CPUInfo: Remove "#X:" prefixes on CPU readings to
improve on-screen readability

Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
Expand Down
@@ -1,18 +1,18 @@
From cc2a3a61ab1f6b375f037681a275907ec91e1694 Mon Sep 17 00:00:00 2001
From 4eebc07f64daab7c269a20b07d0da13b6bdcf90b Mon Sep 17 00:00:00 2001
From: Christian Hewitt <christianshewitt@gmail.com>
Date: Wed, 1 Dec 2021 03:19:59 +0000
Subject: [PATCH 4/5] HACK: AESinkALSA: add some debug logging for ELD status
Subject: [PATCH 4/6] HACK: AESinkALSA: add some debug logging for ELD status

Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
---
xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp | 2 ++
1 file changed, 2 insertions(+)

diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
index 89b497a832..8ff69fe507 100644
index 3e50be7207..dca5b9b7b3 100644
--- a/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
+++ b/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
@@ -1538,9 +1538,11 @@ void CAESinkALSA::EnumerateDevice(AEDeviceInfoList &list, const std::string &dev
@@ -1551,9 +1551,11 @@ void CAESinkALSA::EnumerateDevice(AEDeviceInfoList &list, const std::string &dev
info.m_channels.AddMissingChannels(AEmap);
}
snd_pcm_free_chmaps(alsaMaps);
Expand Down
@@ -1,7 +1,7 @@
From 0a6b7bf7ae0c23085ba5d28cefa1e3269bc54121 Mon Sep 17 00:00:00 2001
From 2234c31674a3776dfeb865ad6dc84f9820739ad9 Mon Sep 17 00:00:00 2001
From: Christian Hewitt <christianshewitt@gmail.com>
Date: Sun, 23 Jan 2022 07:38:32 +0000
Subject: [PATCH 5/5] WinSystemGbmGLESContext: wait longer for vsync
Subject: [PATCH 5/6] WinSystemGbmGLESContext: wait longer for vsync

Waiting longer for vsync improves idle CPU consumption on ARM devices

Expand All @@ -11,10 +11,10 @@ Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xbmc/windowing/gbm/WinSystemGbmGLESContext.cpp b/xbmc/windowing/gbm/WinSystemGbmGLESContext.cpp
index 414dc36963..771747ccbe 100644
index 0d071c31f1..52ae4c1ef2 100644
--- a/xbmc/windowing/gbm/WinSystemGbmGLESContext.cpp
+++ b/xbmc/windowing/gbm/WinSystemGbmGLESContext.cpp
@@ -147,7 +147,7 @@ void CWinSystemGbmGLESContext::PresentRender(bool rendered, bool videoLayer)
@@ -149,7 +149,7 @@ void CWinSystemGbmGLESContext::PresentRender(bool rendered, bool videoLayer)
}
else
{
Expand Down
@@ -0,0 +1,250 @@
From 2cf2850a67d3294bb3056508bf54094bc04fdc0d Mon Sep 17 00:00:00 2001
From: Christian Hewitt <christianshewitt@gmail.com>
Date: Fri, 24 Jun 2022 18:04:13 +0000
Subject: [PATCH 6/6] kodi: hacks and changes for Odroid XU4

---
cmake/modules/FindGBM.cmake | 12 ++--
.../DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp | 66 +++++++++++++++++--
.../DVDCodecs/Video/DVDVideoCodecFFmpeg.h | 1 +
xbmc/windowing/Resolution.cpp | 2 +
xbmc/windowing/gbm/GBMUtils.cpp | 28 ++++----
xbmc/windowing/gbm/WinSystemGbmEGLContext.cpp | 2 +-
xbmc/windowing/gbm/drm/DRMUtils.cpp | 2 +-
7 files changed, 89 insertions(+), 24 deletions(-)

diff --git a/cmake/modules/FindGBM.cmake b/cmake/modules/FindGBM.cmake
index 37a26a7bc4..53cc04663e 100644
--- a/cmake/modules/FindGBM.cmake
+++ b/cmake/modules/FindGBM.cmake
@@ -51,12 +51,12 @@ if(GBM_FOUND)
set(GBM_LIBRARIES ${GBM_LIBRARY})
set(GBM_INCLUDE_DIRS ${GBM_INCLUDE_DIR})
set(GBM_DEFINITIONS -DHAVE_GBM=1)
- if(GBM_HAS_BO_MAP)
- list(APPEND GBM_DEFINITIONS -DHAS_GBM_BO_MAP=1)
- endif()
- if(GBM_HAS_MODIFIERS)
- list(APPEND GBM_DEFINITIONS -DHAS_GBM_MODIFIERS=1)
- endif()
+ #if(GBM_HAS_BO_MAP)
+ # list(APPEND GBM_DEFINITIONS -DHAS_GBM_BO_MAP=1)
+ #endif()
+ #if(GBM_HAS_MODIFIERS)
+ # list(APPEND GBM_DEFINITIONS -DHAS_GBM_MODIFIERS=1)
+ #endif()
if(NOT TARGET GBM::GBM)
add_library(GBM::GBM UNKNOWN IMPORTED)
set_target_properties(GBM::GBM PROPERTIES
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
index a7dc0890e8..ad8c41dcf0 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
@@ -42,6 +42,16 @@ extern "C" {
#define RINT lrint
#endif

+/* define the FFMPEG codecs to use */
+#define MPEG2TS_FFMPEG_CODEC "mpeg2_v4l2m2m"
+#define H263_FFMPEG_CODEC "h263_v4l2m2m"
+#define H264_FFMPEG_CODEC "h264_v4l2m2m"
+#define MPEG4_FFMPEG_CODEC "mpeg4_v4l2m2m"
+#define MPEG1_FFMPEG_CODEC "mpeg1_v4l2m2m"
+#define MPEG2_FFMPEG_CODEC "mpeg2_v4l2m2m"
+#define VC1_FFMPEG_CODEC "vc1_v4l2m2m"
+#define VP8_FFMPEG_CODEC "vp8_v4l2m2m"
+
enum DecoderState
{
STATE_NONE,
@@ -346,6 +356,41 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
pCodec = avcodec_find_decoder_by_name("av1");

if (!pCodec)
+ if(!m_useSoftDecoder)
+ {
+ switch(hints.codec)
+ {
+ case AV_CODEC_ID_MPEG4:
+ pCodec = avcodec_find_decoder_by_name(MPEG4_FFMPEG_CODEC);
+ break;
+ case AV_CODEC_ID_MPEG2TS:
+ pCodec = avcodec_find_decoder_by_name(MPEG2TS_FFMPEG_CODEC);
+ break;
+ case AV_CODEC_ID_H263:
+ pCodec = avcodec_find_decoder_by_name(H263_FFMPEG_CODEC);
+ break;
+ case AV_CODEC_ID_H264:
+ pCodec = avcodec_find_decoder_by_name(H264_FFMPEG_CODEC);
+ break;
+ case AV_CODEC_ID_MPEG1VIDEO:
+ pCodec = avcodec_find_decoder_by_name(MPEG1_FFMPEG_CODEC);
+ break;
+ case AV_CODEC_ID_MPEG2VIDEO:
+ pCodec = avcodec_find_decoder_by_name(MPEG2_FFMPEG_CODEC);
+ break;
+ case AV_CODEC_ID_VC1:
+ pCodec = avcodec_find_decoder_by_name(VC1_FFMPEG_CODEC);
+ break;
+ case AV_CODEC_ID_VP8:
+ pCodec = avcodec_find_decoder_by_name(VP8_FFMPEG_CODEC);
+ break;
+ default:
+ pCodec = avcodec_find_decoder(hints.codec);
+ break;
+ }
+ }
+
+ if(pCodec == NULL)
pCodec = avcodec_find_decoder(hints.codec);

if(pCodec == NULL)
@@ -446,7 +491,7 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
}

UpdateName();
- const char* pixFmtName = av_get_pix_fmt_name(m_pCodecContext->pix_fmt);
+ const char* pixFmtName = av_get_pix_fmt_name(GetFormat(m_pCodecContext, &m_pCodecContext->pix_fmt));
m_processInfo.SetVideoDimensions(m_pCodecContext->coded_width, m_pCodecContext->coded_height);
m_processInfo.SetVideoPixelFormat(pixFmtName ? pixFmtName : "");

@@ -529,15 +574,22 @@ void CDVDVideoCodecFFmpeg::SetFilters()

void CDVDVideoCodecFFmpeg::UpdateName()
{
+ bool isHW = false;
if(m_pCodecContext->codec->name)
+ {
m_name = std::string("ff-") + m_pCodecContext->codec->name;
+ if(strstr(m_pCodecContext->codec->name, "v4l2m2m") != NULL)
+ isHW = true;
+ }
else
m_name = "ffmpeg";

if(m_pHardware)
+ {
m_name += "-" + m_pHardware->Name();
-
- m_processInfo.SetVideoDecoderName(m_name, m_pHardware ? true : false);
+ isHW = true;
+ }
+ m_processInfo.SetVideoDecoderName(m_name, isHW ? true : false);

CLog::Log(LOGDEBUG, "CDVDVideoCodecFFmpeg - Updated codec: {}", m_name);
}
@@ -784,8 +836,14 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecFFmpeg::GetPicture(VideoPicture* pVideoPi
if (m_pDecodedFrame->interlaced_frame)
m_interlaced = true;
else
+ {
m_interlaced = false;
-
+ if (m_useSoftDecoder)
+ {
+ m_useSoftDecoder = false;
+ return VC_REOPEN;
+ }
+ }
if (!m_processInfo.GetVideoInterlaced() && m_interlaced)
m_processInfo.SetVideoInterlaced(m_interlaced);

diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
index 86c83cd1a0..a5552d3350 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
@@ -95,6 +95,7 @@ protected:
bool m_requestSkipDeint = false;
int m_codecControlFlags = 0;
bool m_interlaced = false;
+ bool m_useSoftDecoder = true;
double m_DAR = 1.0;
CDVDStreamInfo m_hints;
CDVDCodecOptions m_options;
diff --git a/xbmc/windowing/Resolution.cpp b/xbmc/windowing/Resolution.cpp
index 4dcd2480ff..78e37add98 100644
--- a/xbmc/windowing/Resolution.cpp
+++ b/xbmc/windowing/Resolution.cpp
@@ -70,6 +70,8 @@ float RESOLUTION_INFO::DisplayRatio() const

RESOLUTION CResolutionUtils::ChooseBestResolution(float fps, int width, int height, bool is3D)
{
+ fps = static_cast<float>(std::round(fps));
+
RESOLUTION res = CServiceBroker::GetWinSystem()->GetGfxContext().GetVideoResolution();
float weight;

diff --git a/xbmc/windowing/gbm/GBMUtils.cpp b/xbmc/windowing/gbm/GBMUtils.cpp
index 5267c93c8f..bc0a9b1c96 100644
--- a/xbmc/windowing/gbm/GBMUtils.cpp
+++ b/xbmc/windowing/gbm/GBMUtils.cpp
@@ -74,24 +74,28 @@ CGBMUtils::CGBMDevice::CGBMSurface::CGBMSurface(gbm_surface* surface) : m_surfac
{
}

+#define MAX_SURFACE_BUFFERS 3
CGBMUtils::CGBMDevice::CGBMSurface::CGBMSurfaceBuffer* CGBMUtils::CGBMDevice::CGBMSurface::
LockFrontBuffer()
{
- m_buffers.emplace(std::make_unique<CGBMSurfaceBuffer>(m_surface));
-
- if (!static_cast<bool>(gbm_surface_has_free_buffers(m_surface)))
+ /* Fix for ODROID XU4, gbm_surface_has_free_buffers doesn't seem to report if there
+ * are no buffers available instead GEM buffers are running out, so we manually empty
+ * the buffers here for a maximum of three
+ */
+ std::call_once(
+ flag, [this]() { CLog::Log(LOGDEBUG, "CGBMUtils - using {} buffers", MAX_SURFACE_BUFFERS); });
+
+ if (m_buffers.size() >= MAX_SURFACE_BUFFERS)
{
- /*
- * We want to use call_once here because we want it to be logged the first time that
- * we have to release buffers. This means that the maximum amount of buffers had been reached.
- * For mesa this should be 4 buffers but it may vary across other implementations.
- */
- std::call_once(
- flag, [this]() { CLog::Log(LOGDEBUG, "CGBMUtils - using {} buffers", m_buffers.size()); });
-
- m_buffers.pop();
+ while (!m_buffers.empty())
+ {
+ m_buffers.front();
+ m_buffers.pop();
+ }
}

+ m_buffers.emplace(std::make_unique<CGBMSurfaceBuffer>(m_surface));
+
return m_buffers.back().get();
}

diff --git a/xbmc/windowing/gbm/WinSystemGbmEGLContext.cpp b/xbmc/windowing/gbm/WinSystemGbmEGLContext.cpp
index 83a59413f7..dbddbbbd55 100644
--- a/xbmc/windowing/gbm/WinSystemGbmEGLContext.cpp
+++ b/xbmc/windowing/gbm/WinSystemGbmEGLContext.cpp
@@ -23,7 +23,7 @@ bool CWinSystemGbmEGLContext::InitWindowSystemEGL(EGLint renderableType, EGLint
return false;
}

- if (!m_eglContext.CreatePlatformDisplay(m_GBM->GetDevice()->Get(), m_GBM->GetDevice()->Get()))
+ if (!m_eglContext.CreatePlatformDisplay(m_GBM->GetDevice()->Get(), reinterpret_cast<EGLNativeDisplayType>(m_GBM->GetDevice()->Get())))
{
return false;
}
diff --git a/xbmc/windowing/gbm/drm/DRMUtils.cpp b/xbmc/windowing/gbm/drm/DRMUtils.cpp
index b424dffe80..9924756b7a 100644
--- a/xbmc/windowing/gbm/drm/DRMUtils.cpp
+++ b/xbmc/windowing/gbm/drm/DRMUtils.cpp
@@ -189,7 +189,7 @@ bool CDRMUtils::FindPlanes()
auto videoPlane = std::find_if(m_planes.begin(), m_planes.end(), [&i](auto& plane) {
if (plane->GetPossibleCrtcs() & (1 << i))
{
- return plane->SupportsFormat(DRM_FORMAT_NV12);
+ return (plane->SupportsFormat(DRM_FORMAT_NV12) || plane->SupportsFormat(DRM_FORMAT_XRGB8888));
}
return false;
});
--
2.17.1

0 comments on commit 2bb2a65

Please sign in to comment.