From 9a6358ee823a92a2126354e0e579965c773cdff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20H=C3=A4rer?= Date: Tue, 22 Oct 2024 01:34:55 +0200 Subject: Revert "Merge pull request #24431 from hbiyik/gbm_drm_dynamic_afbc_video_planes" This reverts commit bf45dda56f7db137303db478073c25e5e0a99cbb, reversing changes made to b4e65aaef8ce82de38caaa3185fa4dad16bc93c2. --- .../VideoPlayer/Buffers/VideoBufferDRMPRIME.h | 2 - .../VideoPlayer/DVDCodecs/Video/DVDVideoCodec.cpp | 2 - .../VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h | 2 - .../DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp | 2 - .../HwDecRender/RendererDRMPRIME.cpp | 2 +- .../HwDecRender/VideoLayerBridgeDRMPRIME.cpp | 11 +- xbmc/windowing/gbm/drm/DRMObject.cpp | 30 ---- xbmc/windowing/gbm/drm/DRMObject.h | 3 - xbmc/windowing/gbm/drm/DRMUtils.cpp | 169 +++++++-------------- xbmc/windowing/gbm/drm/DRMUtils.h | 5 +- 10 files changed, 65 insertions(+), 163 deletions(-) diff --git a/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h b/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h index dca6e82177..b83ee8ca68 100644 --- a/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h +++ b/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h @@ -54,8 +54,6 @@ public: virtual const VideoPicture& GetPicture() const { return m_picture; } virtual uint32_t GetWidth() const { return GetPicture().iWidth; } virtual uint32_t GetHeight() const { return GetPicture().iHeight; } - virtual uint32_t GetXOffset() const { return GetPicture().m_xOffset; } - virtual uint32_t GetYOffset() const { return GetPicture().m_yOffset; } virtual AVDRMFrameDescriptor* GetDescriptor() const = 0; virtual bool IsValid() const { return true; } diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.cpp index a5468d12a0..495d6a25f5 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.cpp @@ -58,8 +58,6 @@ void VideoPicture::Reset() iWidth = 0; iHeight = 0; - m_xOffset = 0; - m_yOffset = 0; iDisplayWidth = 0; iDisplayHeight = 0; } diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h index f3373612e8..ca83b1a04f 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h @@ -75,8 +75,6 @@ public: unsigned int iWidth; unsigned int iHeight; - unsigned int m_xOffset{0}; - unsigned int m_yOffset{0}; unsigned int iDisplayWidth; //< width of the picture without black bars unsigned int iDisplayHeight; //< height of the picture without black bars diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp index 0d407043dd..eb2943bb8c 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp @@ -505,8 +505,6 @@ void CDVDVideoCodecDRMPRIME::SetPictureParams(VideoPicture* pVideoPicture) { pVideoPicture->iWidth = m_pFrame->width; pVideoPicture->iHeight = m_pFrame->height; - pVideoPicture->m_xOffset = m_pFrame->crop_left; - pVideoPicture->m_yOffset = m_pFrame->crop_top; double aspect_ratio = 0; AVRational pixel_aspect = m_pFrame->sample_aspect_ratio; diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererDRMPRIME.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererDRMPRIME.cpp index 2ef7f4d521..66df0e49c7 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererDRMPRIME.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererDRMPRIME.cpp @@ -77,7 +77,7 @@ CBaseRenderer* CRendererDRMPRIME::Create(CVideoBuffer* buffer) if (!plane) return nullptr; - if (!drm->FindVideoPlane(format, modifier)) + if (!plane->SupportsFormatAndModifier(format, modifier)) return nullptr; return new CRendererDRMPRIME(); diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp index 33db29b140..34d1ab6235 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp @@ -118,10 +118,9 @@ bool CVideoLayerBridgeDRMPRIME::Map(CVideoBufferDRMPRIME* buffer) flags = DRM_MODE_FB_MODIFIERS; // add the video frame FB - ret = drmModeAddFB2WithModifiers(m_DRM->GetFileDescriptor(), - buffer->GetWidth() + buffer->GetXOffset(), - buffer->GetHeight() + buffer->GetYOffset(), layer->format, - handles, pitches, offsets, modifier, &buffer->m_fb_id, flags); + ret = drmModeAddFB2WithModifiers(m_DRM->GetFileDescriptor(), buffer->GetWidth(), + buffer->GetHeight(), layer->format, handles, pitches, offsets, + modifier, &buffer->m_fb_id, flags); if (ret < 0) { CLog::Log(LOGERROR, "CVideoLayerBridgeDRMPRIME::{} - failed to add fb {}, ret = {}", @@ -189,8 +188,8 @@ void CVideoLayerBridgeDRMPRIME::SetVideoPlane(CVideoBufferDRMPRIME* buffer, cons auto plane = m_DRM->GetVideoPlane(); m_DRM->AddProperty(plane, "FB_ID", buffer->m_fb_id); m_DRM->AddProperty(plane, "CRTC_ID", m_DRM->GetCrtc()->GetCrtcId()); - m_DRM->AddProperty(plane, "SRC_X", buffer->GetXOffset() << 16); - m_DRM->AddProperty(plane, "SRC_Y", buffer->GetYOffset() << 16); + m_DRM->AddProperty(plane, "SRC_X", 0); + m_DRM->AddProperty(plane, "SRC_Y", 0); m_DRM->AddProperty(plane, "SRC_W", buffer->GetWidth() << 16); m_DRM->AddProperty(plane, "SRC_H", buffer->GetHeight() << 16); m_DRM->AddProperty(plane, "CRTC_X", static_cast(destRect.x1) & ~1); diff --git a/xbmc/windowing/gbm/drm/DRMObject.cpp b/xbmc/windowing/gbm/drm/DRMObject.cpp index 99dda24490..5ffce40fa3 100644 --- a/xbmc/windowing/gbm/drm/DRMObject.cpp +++ b/xbmc/windowing/gbm/drm/DRMObject.cpp @@ -105,25 +105,6 @@ std::optional CDRMObject::GetPropertyValue(std::string_view name, return {}; } -std::optional> CDRMObject::GetRangePropertyLimits(std::string_view name) -{ - auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), - [&name](const auto& prop) { return prop->name == name; }); - - if (property == m_propsInfo.end()) - return {}; - - auto prop = property->get(); - - if (!static_cast(drm_property_type_is(prop, DRM_MODE_PROP_RANGE))) - return {}; - - if (prop->count_values != 2) - return {}; - - return std::make_optional>(prop->values, 2); -} - bool CDRMObject::SetProperty(const std::string& name, uint64_t value) { auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), @@ -149,14 +130,3 @@ bool CDRMObject::SupportsProperty(const std::string& name) return false; } - -std::optional CDRMObject::IsPropertyImmutable(std::string_view name) -{ - auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), - [&name](const auto& prop) { return prop->name == name; }); - - if (property == m_propsInfo.end()) - return {}; - - return static_cast(drm_property_type_is(property->get(), DRM_MODE_PROP_IMMUTABLE)); -} diff --git a/xbmc/windowing/gbm/drm/DRMObject.h b/xbmc/windowing/gbm/drm/DRMObject.h index 39ba28a004..c4200b1a86 100644 --- a/xbmc/windowing/gbm/drm/DRMObject.h +++ b/xbmc/windowing/gbm/drm/DRMObject.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -41,8 +40,6 @@ public: bool SetProperty(const std::string& name, uint64_t value); bool SupportsProperty(const std::string& name); - std::optional IsPropertyImmutable(std::string_view name); - std::optional> GetRangePropertyLimits(std::string_view name); protected: explicit CDRMObject(int fd); diff --git a/xbmc/windowing/gbm/drm/DRMUtils.cpp b/xbmc/windowing/gbm/drm/DRMUtils.cpp index 22db758ab6..3dd4ee9783 100644 --- a/xbmc/windowing/gbm/drm/DRMUtils.cpp +++ b/xbmc/windowing/gbm/drm/DRMUtils.cpp @@ -181,130 +181,77 @@ bool CDRMUtils::FindPreferredMode() return true; } -bool CDRMUtils::FindGuiPlane() +bool CDRMUtils::FindPlanes() { - /* find the gui plane which support ARGB and 8bit or 10 bit XRGB - * prefer the one which does not support NV12, because it can be re-used in future for video - * prefer the highest id number because they are listed on top where zpos is not available - * and use the gui plane crtc as the crtc - * */ - CDRMPlane* gui_plane_nv12{nullptr}; - CDRMPlane* gui_plane{nullptr}; - CDRMCrtc* gui_crtc_nv12{nullptr}; - CDRMCrtc* gui_crtc{nullptr}; - - for (size_t crtc_offset = 0; crtc_offset < m_crtcs.size(); crtc_offset++) - { - if (!(m_encoder->GetPossibleCrtcs() & (1 << crtc_offset))) + for (size_t i = 0; i < m_crtcs.size(); i++) + { + if (!(m_encoder->GetPossibleCrtcs() & (1 << i))) continue; - for (auto& plane : m_planes) + 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 false; + }); + + uint32_t videoPlaneId{0}; + + if (videoPlane != m_planes.end()) + videoPlaneId = videoPlane->get()->GetPlaneId(); + + auto guiPlane = + std::find_if(m_planes.begin(), m_planes.end(), [&i, &videoPlaneId](auto& plane) { + if (plane->GetPossibleCrtcs() & (1 << i)) + { + return (plane->GetPlaneId() != videoPlaneId && + (videoPlaneId == 0 || plane->SupportsFormat(DRM_FORMAT_ARGB8888)) && + (plane->SupportsFormat(DRM_FORMAT_XRGB2101010) || + plane->SupportsFormat(DRM_FORMAT_XRGB8888))); + } + return false; + }); + + if (videoPlane != m_planes.end() && guiPlane != m_planes.end()) { - if (!(plane.get()->GetPossibleCrtcs() & (1 << crtc_offset))) - continue; + m_crtc = m_crtcs[i].get(); + m_video_plane = videoPlane->get(); + m_gui_plane = guiPlane->get(); + break; + } - if (plane.get()->SupportsFormat(DRM_FORMAT_ARGB8888) && - (plane.get()->SupportsFormat(DRM_FORMAT_XRGB2101010) || - plane.get()->SupportsFormat(DRM_FORMAT_XRGB8888))) + if (guiPlane != m_planes.end()) + { + if (!m_crtc && m_encoder->GetCrtcId() == m_crtcs[i]->GetCrtcId()) { - if (plane.get()->SupportsFormat(DRM_FORMAT_NV12) && - (gui_plane_nv12 == nullptr || gui_plane_nv12->GetId() < plane.get()->GetId())) - { - gui_plane_nv12 = plane.get(); - gui_crtc_nv12 = m_crtcs[crtc_offset].get(); - } - else if (!plane.get()->SupportsFormat(DRM_FORMAT_NV12) && - (gui_plane == nullptr || gui_plane->GetId() < plane.get()->GetId())) - { - gui_plane = plane.get(); - gui_crtc = m_crtcs[crtc_offset].get(); - } + m_crtc = m_crtcs[i].get(); + m_gui_plane = guiPlane->get(); + m_video_plane = nullptr; } } } - // fallback to NV12 supporting plane - if (gui_plane == nullptr) - { - gui_crtc = gui_crtc_nv12; - gui_plane = gui_plane_nv12; - } + CLog::Log(LOGINFO, "CDRMUtils::{} - using crtc: {}", __FUNCTION__, m_crtc->GetCrtcId()); - if (gui_plane != nullptr) - { - m_crtc = gui_crtc; - m_gui_plane = gui_plane; + // video plane may not be available + if (m_video_plane) + CLog::Log(LOGDEBUG, "CDRMUtils::{} - using video plane {}", __FUNCTION__, + m_video_plane->GetPlaneId()); - CLog::Log(LOGINFO, "CDRMUtils::{} - using crtc: {}", __FUNCTION__, m_crtc->GetCrtcId()); - if (m_gui_plane->SupportsFormat(DRM_FORMAT_XRGB2101010)) - { - m_gui_plane->SetFormat(DRM_FORMAT_XRGB2101010); - CLog::Log(LOGDEBUG, "CDRMUtils::{} - using 10bit gui plane {}", __FUNCTION__, - m_gui_plane->GetPlaneId()); - } - else - { - m_gui_plane->SetFormat(DRM_FORMAT_XRGB8888); - CLog::Log(LOGDEBUG, "CDRMUtils::{} - using gui plane {}", __FUNCTION__, - m_gui_plane->GetPlaneId()); - } - return true; + if (m_gui_plane->SupportsFormat(DRM_FORMAT_XRGB2101010)) + { + m_gui_plane->SetFormat(DRM_FORMAT_XRGB2101010); + CLog::Log(LOGDEBUG, "CDRMUtils::{} - using 10bit gui plane {}", __FUNCTION__, + m_gui_plane->GetPlaneId()); } - - CLog::Log(LOGERROR, "CDRMUtils::{} - Can not find a GUI plane", __FUNCTION__); - return false; -} - -bool CDRMUtils::FindVideoPlane(uint32_t format, uint64_t modifier) -{ - bool supports_zpos = m_gui_plane->SupportsProperty("zpos"); - bool zpos_immutable = supports_zpos && m_gui_plane->IsPropertyImmutable("zpos").value(); - - auto crtc_offset = std::distance( - m_crtcs.begin(), - std::find_if(m_crtcs.begin(), m_crtcs.end(), - [this](auto& crtc) { return crtc->GetCrtcId() == m_crtc->GetCrtcId(); })); - - auto guiplane_id = m_gui_plane->GetId(); - auto videoPlane = std::find_if(m_planes.begin(), m_planes.end(), - [&crtc_offset, &format, &modifier, &guiplane_id](auto& plane) - { - if (plane->GetPossibleCrtcs() & (1 << crtc_offset)) - { - return (guiplane_id != plane->GetPlaneId() && - plane->SupportsFormatAndModifier(format, modifier)); - } - return false; - }); - - if (videoPlane == m_planes.end()) - { - CLog::Log(LOGERROR, - "CDRMUtils::{} - Can not find a Video Plane plane for format {}, modifier {}", - __FUNCTION__, format, modifier); - return false; + else + { + m_gui_plane->SetFormat(DRM_FORMAT_XRGB8888); + CLog::Log(LOGDEBUG, "CDRMUtils::{} - using gui plane {}", __FUNCTION__, + m_gui_plane->GetPlaneId()); } - m_video_plane = videoPlane->get(); - CLog::Log(LOGDEBUG, "CDRMUtils::{} - using video plane {}", __FUNCTION__, - m_video_plane->GetPlaneId()); - - if (!supports_zpos || zpos_immutable) - return true; - - // re-sort the video and gui planes - auto limits = m_gui_plane->GetRangePropertyLimits("zpos"); - - if (!limits) - return true; - - m_gui_plane->SetProperty("zpos", limits.value()[1]); - m_video_plane->SetProperty("zpos", limits.value()[0]); - CLog::Log(LOGDEBUG, "CDRMUtils::{} - gui plane id,zpos: {}, {}", __FUNCTION__, - m_gui_plane->GetId(), limits.value()[1]); - CLog::Log(LOGDEBUG, "CDRMUtils::{} - video plane id,zpos: {}, {}", __FUNCTION__, - m_video_plane->GetId(), limits.value()[0]); - return true; } @@ -520,11 +467,9 @@ bool CDRMUtils::InitDrm() if (!FindCrtc()) return false; - if (!FindGuiPlane()) + if (!FindPlanes()) return false; - FindVideoPlane(DRM_FORMAT_NV12, DRM_FORMAT_MOD_LINEAR); - if (!FindPreferredMode()) return false; diff --git a/xbmc/windowing/gbm/drm/DRMUtils.h b/xbmc/windowing/gbm/drm/DRMUtils.h index b99a6dc4fe..f92f716fc4 100644 --- a/xbmc/windowing/gbm/drm/DRMUtils.h +++ b/xbmc/windowing/gbm/drm/DRMUtils.h @@ -64,8 +64,6 @@ public: static uint32_t FourCCWithoutAlpha(uint32_t fourcc); void SetInFenceFd(int fd) { m_inFenceFd = fd; } - bool FindVideoPlane(uint32_t format, uint64_t modifier); - bool FindGuiPlane(); int TakeOutFenceFd() { int fd{-1}; @@ -91,13 +89,13 @@ protected: int m_inFenceFd{-1}; int m_outFenceFd{-1}; - std::vector> m_crtcs; std::vector> m_planes; private: bool FindConnector(); bool FindEncoder(); bool FindCrtc(); + bool FindPlanes(); bool FindPreferredMode(); bool RestoreOriginalMode(); RESOLUTION_INFO GetResolutionInfo(drmModeModeInfoPtr mode); @@ -108,6 +106,7 @@ private: std::vector> m_connectors; std::vector> m_encoders; + std::vector> m_crtcs; }; } -- cgit v1.2.3