From 868de36dedb1aac6d481de93d0d981814311a82c Mon Sep 17 00:00:00 2001 From: MilhouseVH Date: Fri, 16 Feb 2018 05:18:46 +0000 Subject: [PATCH] kodi: add PR13552 (amlcodec: cleanup and simplify 3D handling code) --- .../kodi/patches/kodi-999.99-PR13552.patch | 349 ++++++++++++++++++ 1 file changed, 349 insertions(+) create mode 100644 packages/mediacenter/kodi/patches/kodi-999.99-PR13552.patch diff --git a/packages/mediacenter/kodi/patches/kodi-999.99-PR13552.patch b/packages/mediacenter/kodi/patches/kodi-999.99-PR13552.patch new file mode 100644 index 0000000000..d3d8032ec2 --- /dev/null +++ b/packages/mediacenter/kodi/patches/kodi-999.99-PR13552.patch @@ -0,0 +1,349 @@ +From ec9e4d1fe085d585b6107fb0bb27645506b540f3 Mon Sep 17 00:00:00 2001 +From: Alex Deryskyba +Date: Thu, 15 Feb 2018 21:48:16 +0200 +Subject: [PATCH] amlcodec: cleanup and simplify 3D handling code + +--- + .../cores/VideoPlayer/DVDCodecs/Video/AMLCodec.cpp | 178 ++++----------------- + xbmc/cores/VideoPlayer/DVDCodecs/Video/AMLCodec.h | 7 +- + xbmc/utils/AMLUtils.cpp | 20 --- + xbmc/utils/AMLUtils.h | 1 - + 4 files changed, 30 insertions(+), 176 deletions(-) + +diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/AMLCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/AMLCodec.cpp +index d83fbda65bd4..d8a14fed1a25 100644 +--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/AMLCodec.cpp ++++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/AMLCodec.cpp +@@ -55,8 +55,7 @@ + + // amcodec include + extern "C" { +-#include +-#include ++#include + } // extern "C" + + CEvent g_aml_sync_event; +@@ -346,44 +345,6 @@ typedef struct vframe_states + int buf_avail_num; + } vframe_states_t; + +-static int aml_ioctl_get(CODEC_HANDLE h, int subcmd, unsigned long paramter) +-{ +- struct am_ioctl_parm parm; +- memset(&parm, 0, sizeof(parm)); +- parm.cmd = subcmd; +- parm.data_32 = *(unsigned int *)paramter; +- if (ioctl(h, AMSTREAM_IOC_GET, (unsigned long)&parm) < 0) +- { +- CLog::Log(LOGERROR, "aml_ioctl_get failed: subcmd=%x, errno=%d", subcmd, errno); +- return -1; +- } +- *(unsigned int *)paramter = parm.data_32; +- return 0; +-} +- +- +-#ifndef AMSTREAM_IOC_MAGIC +-#define AMSTREAM_IOC_MAGIC 'S' +-#endif +- +-#ifndef AMSTREAM_IOC_VF_STATUS +-#define AMSTREAM_IOC_VF_STATUS _IOR(AMSTREAM_IOC_MAGIC, 0x60, unsigned long) +-#endif +- +-#ifndef AMSTREAM_IOC_GET_3D_TYPE +-#define AMSTREAM_IOC_GET_3D_TYPE _IOW((AMSTREAM_IOC_MAGIC), 0x3d, unsigned int) +-#endif +- +- +-enum +-{ +- VPP_3D_MODE_NULL = 0, +- VPP_3D_MODE_LR, +- VPP_3D_MODE_TB, +- VPP_3D_MODE_LA, +- VPP_3D_MODE_FA +-}; +- + /*************************************************************************/ + /*************************************************************************/ + void dumpfile_open(am_private_t *para) +@@ -2264,53 +2225,21 @@ void CAMLCodec::SetVideoSaturation(const int saturation) + SysfsUtils::SetInt("/sys/class/video/saturation", saturation); + } + +-bool CAMLCodec::SetVideo3dMode(const int mode3d) +-{ +- bool result = true; +- if (SysfsUtils::Has("/sys/class/ppmgr/ppmgr_3d_mode")) +- { +- CLog::Log(LOGDEBUG, "CAMLCodec::SetVideo3dMode:mode3d(0x%x)", mode3d); +- SysfsUtils::SetInt("/sys/class/ppmgr/ppmgr_3d_mode", mode3d); +- } +- else +- { +- CLog::Log(LOGINFO, "CAMLCodec::SetVideo3dMode: ppmgr_3d support not found in kernel."); +- result = false; +- } +- return result; +-} +- +-std::string CAMLCodec::GetStereoMode() ++std::string CAMLCodec::GetVideoStereoMode() + { + std::string stereoMode; + +- //Get Decoder Stereo mode +- int decoder_sm(VPP_3D_MODE_NULL); +- aml_ioctl_get(am_private->vcodec.handle, AMSTREAM_IOC_GET_3D_TYPE, (unsigned long)&decoder_sm); +- +- switch (decoder_sm) ++ switch (m_processInfo.GetVideoSettings().m_StereoMode) + { +- case VPP_3D_MODE_LR: ++ case RENDER_STEREO_MODE_SPLIT_VERTICAL: + stereoMode = "left_right"; + break; +- case VPP_3D_MODE_TB: ++ case RENDER_STEREO_MODE_SPLIT_HORIZONTAL: + stereoMode = "top_bottom"; + break; +- case VPP_3D_MODE_LA: +- case VPP_3D_MODE_FA: + default: +- switch(m_processInfo.GetVideoSettings().m_StereoMode) +- { +- case RENDER_STEREO_MODE_SPLIT_VERTICAL: +- stereoMode = "left_right"; +- break; +- case RENDER_STEREO_MODE_SPLIT_HORIZONTAL: +- stereoMode = "top_bottom"; +- break; +- default: +- stereoMode = m_hints.stereo_mode; +- break; +- } ++ stereoMode = m_hints.stereo_mode; ++ break; + } + + if (m_processInfo.GetVideoSettings().m_StereoInvert) +@@ -2320,6 +2249,7 @@ std::string CAMLCodec::GetStereoMode() + else if (stereoMode == "left_right") + stereoMode = "right_left"; + } ++ + return stereoMode; + } + +@@ -2359,20 +2289,20 @@ void CAMLCodec::SetVideoRect(const CRect &SrcRect, const CRect &DestRect) + update = true; + } + +- // video stereo mode/view. +- RENDER_STEREO_MODE stereo_mode = g_graphicsContext.GetStereoMode(); +- if (m_stereo_mode != stereo_mode) ++ // GUI stereo mode/view. ++ RENDER_STEREO_MODE guiStereoMode = g_graphicsContext.GetStereoMode(); ++ if (m_guiStereoMode != guiStereoMode) + { +- m_stereo_mode = stereo_mode; ++ m_guiStereoMode = guiStereoMode; + update = true; + } +- RENDER_STEREO_VIEW stereo_view = g_graphicsContext.GetStereoView(); +- if (m_stereo_view != stereo_view) ++ RENDER_STEREO_VIEW guiStereoView = g_graphicsContext.GetStereoView(); ++ if (m_guiStereoView != guiStereoView) + { + // left/right/top/bottom eye, + // this might change every other frame. + // we do not care but just track it. +- m_stereo_view = stereo_view; ++ m_guiStereoView = guiStereoView; + } + + // dest_rect +@@ -2424,9 +2354,9 @@ void CAMLCodec::SetVideoRect(const CRect &SrcRect, const CRect &DestRect) + { + float xscale = display.Width() / gui.Width(); + float yscale = display.Height() / gui.Height(); +- if (m_stereo_mode == RENDER_STEREO_MODE_SPLIT_VERTICAL) ++ if (m_guiStereoMode == RENDER_STEREO_MODE_SPLIT_VERTICAL) + xscale /= 2.0; +- else if (m_stereo_mode == RENDER_STEREO_MODE_SPLIT_HORIZONTAL) ++ else if (m_guiStereoMode == RENDER_STEREO_MODE_SPLIT_HORIZONTAL) + yscale /= 2.0; + dst_rect.x1 *= xscale; + dst_rect.x2 *= xscale; +@@ -2434,75 +2364,21 @@ void CAMLCodec::SetVideoRect(const CRect &SrcRect, const CRect &DestRect) + dst_rect.y2 *= yscale; + } + +- if (m_stereo_mode == RENDER_STEREO_MODE_MONO) ++ if (m_guiStereoMode == RENDER_STEREO_MODE_MONO) + { +- std::string mode = GetStereoMode(); +- if (mode == "left_right") +- { +- if (!SetVideo3dMode(MODE_3D_TO_2D_L)) +- { +- // fall back to software scaling if no hw support +- // was found +- dst_rect.x2 *= 2.0; +- } +- } +- else if (mode == "right_left") +- { +- if (!SetVideo3dMode(MODE_3D_TO_2D_R)) +- { +- // fall back to software scaling if no hw support +- // was found +- dst_rect.x2 *= 2.0; +- } +- } +- else if (mode == "top_bottom") +- { +- if (!SetVideo3dMode(MODE_3D_TO_2D_T)) +- { +- // fall back to software scaling if no hw support +- // was found +- dst_rect.y2 *= 2.0; +- } +- } +- else if (mode == "bottom_top") +- { +- if (!SetVideo3dMode(MODE_3D_TO_2D_B)) +- { +- // fall back to software scaling if no hw support +- // was found +- dst_rect.y2 *= 2.0; +- } +- } +- else +- SetVideo3dMode(MODE_3D_DISABLE); ++ std::string videoStereoMode = GetVideoStereoMode(); ++ if (videoStereoMode == "left_right" || videoStereoMode == "righ_left") ++ dst_rect.x2 *= 2.0; ++ else if (videoStereoMode == "top_bottom" || videoStereoMode == "bottom_top") ++ dst_rect.y2 *= 2.0; + } +- else if (m_stereo_mode == RENDER_STEREO_MODE_SPLIT_VERTICAL) ++ else if (m_guiStereoMode == RENDER_STEREO_MODE_SPLIT_VERTICAL) + { + dst_rect.x2 *= 2.0; +- SetVideo3dMode(MODE_3D_DISABLE); + } +- else if (m_stereo_mode == RENDER_STEREO_MODE_SPLIT_HORIZONTAL) ++ else if (m_guiStereoMode == RENDER_STEREO_MODE_SPLIT_HORIZONTAL) + { + dst_rect.y2 *= 2.0; +- SetVideo3dMode(MODE_3D_DISABLE); +- } +- else if (m_stereo_mode == RENDER_STEREO_MODE_INTERLACED) +- { +- std::string mode = GetStereoMode(); +- if (mode == "left_right") +- SetVideo3dMode(MODE_3D_LR); +- else if (mode == "right_left") +- SetVideo3dMode(MODE_3D_LR_SWITCH); +- else if (mode == "row_interleaved_lr") +- SetVideo3dMode(MODE_3D_LR); +- else if (mode == "row_interleaved_rl") +- SetVideo3dMode(MODE_3D_LR_SWITCH); +- else +- SetVideo3dMode(MODE_3D_DISABLE); +- } +- else +- { +- SetVideo3dMode(MODE_3D_DISABLE); + } + + #if 1 +@@ -2522,8 +2398,8 @@ void CAMLCodec::SetVideoRect(const CRect &SrcRect, const CRect &DestRect) + CLog::Log(LOGDEBUG, "CAMLCodec::SetVideoRect:gui(%s)", s_gui.c_str()); + CLog::Log(LOGDEBUG, "CAMLCodec::SetVideoRect:m_dst_rect(%s)", s_m_dst_rect.c_str()); + CLog::Log(LOGDEBUG, "CAMLCodec::SetVideoRect:dst_rect(%s)", s_dst_rect.c_str()); +- CLog::Log(LOGDEBUG, "CAMLCodec::SetVideoRect:m_stereo_mode(%d)", m_stereo_mode); +- CLog::Log(LOGDEBUG, "CAMLCodec::SetVideoRect:m_stereo_view(%d)", m_stereo_view); ++ CLog::Log(LOGDEBUG, "CAMLCodec::SetVideoRect:m_guiStereoMode(%d)", m_guiStereoMode); ++ CLog::Log(LOGDEBUG, "CAMLCodec::SetVideoRect:m_guiStereoView(%d)", m_guiStereoView); + #endif + + // goofy 0/1 based difference in aml axis coordinates. +diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/AMLCodec.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/AMLCodec.h +index 378c237c3b38..fdb1b63fffe1 100644 +--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/AMLCodec.h ++++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/AMLCodec.h +@@ -71,8 +71,7 @@ class CAMLCodec + void SetVideoContrast(const int contrast); + void SetVideoBrightness(const int brightness); + void SetVideoSaturation(const int saturation); +- bool SetVideo3dMode(const int mode3d); +- std::string GetStereoMode(); ++ std::string GetVideoStereoMode(); + bool OpenAmlVideo(const CDVDStreamInfo &hints); + void CloseAmlVideo(); + std::string GetVfmMap(const std::string &name); +@@ -96,8 +95,8 @@ class CAMLCodec + CRect m_display_rect; + + int m_view_mode = -1; +- RENDER_STEREO_MODE m_stereo_mode = RENDER_STEREO_MODE_OFF; +- RENDER_STEREO_VIEW m_stereo_view = RENDER_STEREO_VIEW_OFF; ++ RENDER_STEREO_MODE m_guiStereoMode = RENDER_STEREO_MODE_OFF; ++ RENDER_STEREO_VIEW m_guiStereoView = RENDER_STEREO_VIEW_OFF; + float m_zoom = -1.0f; + int m_contrast = -1; + int m_brightness = -1; +diff --git a/xbmc/utils/AMLUtils.cpp b/xbmc/utils/AMLUtils.cpp +index 5666236e93a5..9ba833838ff4 100644 +--- a/xbmc/utils/AMLUtils.cpp ++++ b/xbmc/utils/AMLUtils.cpp +@@ -54,22 +54,6 @@ bool aml_present() + return has_aml == 1; + } + +-bool aml_hw3d_present() +-{ +- static int has_hw3d = -1; +- if (has_hw3d == -1) +- { +- if (SysfsUtils::Has("/sys/class/ppmgr/ppmgr_3d_mode") || +- SysfsUtils::Has("/sys/class/amhdmitx/amhdmitx0/config")) +- has_hw3d = 1; +- else +- has_hw3d = 0; +- if (has_hw3d) +- CLog::Log(LOGNOTICE, "AML 3D support detected"); +- } +- return has_hw3d == 1; +-} +- + bool aml_wired_present() + { + static int has_wired = -1; +@@ -138,10 +122,6 @@ bool aml_permissions() + { + CLog::Log(LOGERROR, "AML: no rw on /sys/class/audiodsp/digital_raw"); + } +- if (!SysfsUtils::HasRW("/sys/class/ppmgr/ppmgr_3d_mode")) +- { +- CLog::Log(LOGERROR, "AML: no rw on /sys/class/ppmgr/ppmgr_3d_mode"); +- } + if (!SysfsUtils::HasRW("/sys/class/amhdmitx/amhdmitx0/config")) + { + CLog::Log(LOGERROR, "AML: no rw on /sys/class/amhdmitx/amhdmitx0/config"); +diff --git a/xbmc/utils/AMLUtils.h b/xbmc/utils/AMLUtils.h +index a012d1b0aedc..1fc7dab3e3b3 100644 +--- a/xbmc/utils/AMLUtils.h ++++ b/xbmc/utils/AMLUtils.h +@@ -54,7 +54,6 @@ enum AML_SUPPORT_H264_4K2K + + bool aml_present(); + bool aml_permissions(); +-bool aml_hw3d_present(); + bool aml_wired_present(); + bool aml_support_hevc(); + bool aml_support_hevc_4k2k();