Skip to content

Commit

Permalink
Merge pull request xbmc#6462 from glenvt18/videosync_drm_crtc
Browse files Browse the repository at this point in the history
[videosync] drm: fix multi-head.
  • Loading branch information
FernetMenta committed Feb 17, 2015
2 parents c29f390 + 5574507 commit 58ce5af
Showing 1 changed file with 22 additions and 33 deletions.
55 changes: 22 additions & 33 deletions xbmc/video/videosync/VideoSyncDRM.cpp
Expand Up @@ -32,6 +32,22 @@
#include "guilib/GraphicContext.h"
#include "utils/log.h"

static drmVBlankSeqType CrtcSel(void)
{
int crtc = g_Windowing.GetCrtc();
int ret = 0;

if (crtc == 1)
{
ret = DRM_VBLANK_SECONDARY;
}
else if (crtc > 1)
{
ret = (crtc << DRM_VBLANK_HIGH_CRTC_SHIFT) & DRM_VBLANK_HIGH_CRTC_MASK;
}
return (drmVBlankSeqType)ret;
}

bool CVideoSyncDRM::Setup(PUPDATECLOCK func)
{
CLog::Log(LOGDEBUG, "CVideoSyncDRM::%s - setting up DRM", __FUNCTION__);
Expand All @@ -47,7 +63,7 @@ bool CVideoSyncDRM::Setup(PUPDATECLOCK func)

drmVBlank vbl;
int ret;
vbl.request.type = DRM_VBLANK_RELATIVE;
vbl.request.type = (drmVBlankSeqType)(DRM_VBLANK_RELATIVE | CrtcSel());
vbl.request.sequence = 0;
ret = drmWaitVBlank(m_fd, &vbl);
if (ret != 0)
Expand All @@ -67,18 +83,9 @@ void CVideoSyncDRM::Run(volatile bool& stop)
drmVBlank vbl;
VblInfo info;
int ret;
int crtc = g_Windowing.GetCrtc();
drmVBlankSeqType crtcSel = CrtcSel();

vbl.request.type = DRM_VBLANK_RELATIVE;
if (crtc == 1)
{
vbl.request.type = (drmVBlankSeqType)(vbl.request.type | DRM_VBLANK_SECONDARY);
}
else if (crtc > 1)
{
vbl.request.type = (drmVBlankSeqType)(vbl.request.type |
((crtc << DRM_VBLANK_HIGH_CRTC_SHIFT) & DRM_VBLANK_HIGH_CRTC_MASK));
}
vbl.request.type = (drmVBlankSeqType)(DRM_VBLANK_RELATIVE | crtcSel);
vbl.request.sequence = 0;
ret = drmWaitVBlank(m_fd, &vbl);
if (ret != 0)
Expand All @@ -90,16 +97,7 @@ void CVideoSyncDRM::Run(volatile bool& stop)
info.start = CurrentHostCounter();
info.videoSync = this;

vbl.request.type = (drmVBlankSeqType)(DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT);
if (crtc == 1)
{
vbl.request.type = (drmVBlankSeqType)(vbl.request.type | DRM_VBLANK_SECONDARY);
}
else if (crtc > 1)
{
vbl.request.type = (drmVBlankSeqType)(vbl.request.type |
((crtc << DRM_VBLANK_HIGH_CRTC_SHIFT) & DRM_VBLANK_HIGH_CRTC_MASK));
}
vbl.request.type = (drmVBlankSeqType)(DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT | crtcSel);
vbl.request.sequence = 1;
vbl.request.signal = (unsigned long)&info;
ret = drmWaitVBlank(m_fd, &vbl);
Expand Down Expand Up @@ -151,18 +149,9 @@ void CVideoSyncDRM::EventHandler(int fd, unsigned int frame, unsigned int sec,
{
drmVBlank vbl;
VblInfo *info = (VblInfo*)data;
int crtc = g_Windowing.GetCrtc();
drmVBlankSeqType crtcSel = CrtcSel();

vbl.request.type = (drmVBlankSeqType)(DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT);
if (crtc == 1)
{
vbl.request.type = (drmVBlankSeqType)(vbl.request.type | DRM_VBLANK_SECONDARY);
}
else if (crtc > 1)
{
vbl.request.type = (drmVBlankSeqType)(vbl.request.type |
((crtc << DRM_VBLANK_HIGH_CRTC_SHIFT) & DRM_VBLANK_HIGH_CRTC_MASK));
}
vbl.request.type = (drmVBlankSeqType)(DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT | crtcSel);
vbl.request.sequence = 1;
vbl.request.signal = (unsigned long)data;

Expand Down

0 comments on commit 58ce5af

Please sign in to comment.