Skip to content

Commit

Permalink
pi4: hack: Try to hide pixel wrap issue
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed Feb 26, 2021
1 parent 0911d8e commit f3a9069
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h"
#include "utils/log.h"
#include "windowing/gbm/drm/DRMAtomic.h"
#include "settings/DisplaySettings.h"

#include <utility>

Expand Down Expand Up @@ -264,13 +265,24 @@ 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());

uint32_t srcw = buffer->GetWidth() << 16;
uint32_t dstw = static_cast<uint32_t>(destRect.Width());
uint32_t dstx = static_cast<int32_t>(destRect.x1);
double scalex = (double)srcw / (double)dstw;
RESOLUTION_INFO &res = CDisplaySettings::GetInstance().GetCurrentResolutionInfo();
if (dstw > 2 && dstx + dstw > (uint32_t)res.iScreenWidth - 2)
{
dstw -= 2;
srcw = (uint32_t)(srcw - 2.0 * scalex + 0.5);
}
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_W", srcw);
m_DRM->AddProperty(plane, "SRC_H", buffer->GetHeight() << 16);
m_DRM->AddProperty(plane, "CRTC_X", static_cast<int32_t>(destRect.x1) & ~1);
m_DRM->AddProperty(plane, "CRTC_X", (dstx + 1) & ~1);
m_DRM->AddProperty(plane, "CRTC_Y", static_cast<int32_t>(destRect.y1) & ~1);
m_DRM->AddProperty(plane, "CRTC_W", (static_cast<uint32_t>(destRect.Width()) + 1) & ~1);
m_DRM->AddProperty(plane, "CRTC_W", (dstw + 1) & ~1);
m_DRM->AddProperty(plane, "CRTC_H", (static_cast<uint32_t>(destRect.Height()) + 1) & ~1);
}

Expand Down
10 changes: 8 additions & 2 deletions xbmc/windowing/gbm/drm/DRMAtomic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,19 @@ void CDRMAtomic::DrmAtomicCommit(int fb_id, int flags, bool rendered, bool video
return;
}

uint32_t srcw = m_width << 16;
uint32_t dstw = m_mode->hdisplay;
double scalex = (double)srcw / (double)dstw;
dstw -= 2;
srcw = (uint32_t)(srcw - 2.0 * scalex + 0.5);

if (rendered)
{
AddProperty(m_gui_plane, "FB_ID", fb_id);
AddProperty(m_gui_plane, "CRTC_ID", m_crtc->GetCrtcId());
AddProperty(m_gui_plane, "SRC_X", 0);
AddProperty(m_gui_plane, "SRC_Y", 0);
AddProperty(m_gui_plane, "SRC_W", m_width << 16);
AddProperty(m_gui_plane, "SRC_W", srcw);
AddProperty(m_gui_plane, "SRC_H", m_height << 16);
AddProperty(m_gui_plane, "CRTC_X", 0);
AddProperty(m_gui_plane, "CRTC_Y", 0);
Expand All @@ -109,7 +115,7 @@ void CDRMAtomic::DrmAtomicCommit(int fb_id, int flags, bool rendered, bool video
// }
// else
{
AddProperty(m_gui_plane, "CRTC_W", m_mode->hdisplay);
AddProperty(m_gui_plane, "CRTC_W", dstw);
AddProperty(m_gui_plane, "CRTC_H", m_mode->vdisplay);
}

Expand Down

0 comments on commit f3a9069

Please sign in to comment.