aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRainer Hochecker <fernetmenta@online.de>2014-10-15 13:21:07 +0200
committerRainer Hochecker <fernetmenta@online.de>2014-10-31 21:45:12 +0100
commitcadfd73ad6f7c288283ec0170740f28b138e703f (patch)
tree6d55ef123d1cc47d9fab50ba23c37da452d0d6c2
parentce924e98a4f6be2e31dec8fa5846307cbe56f273 (diff)
X11: expose crtc needed by drm video sync
-rw-r--r--xbmc-xrandr.c4
-rw-r--r--xbmc/windowing/X11/WinSystemX11.cpp23
-rw-r--r--xbmc/windowing/X11/WinSystemX11.h3
-rw-r--r--xbmc/windowing/X11/XRandR.cpp19
-rw-r--r--xbmc/windowing/X11/XRandR.h2
5 files changed, 46 insertions, 5 deletions
diff --git a/xbmc-xrandr.c b/xbmc-xrandr.c
index 3c686e2059..7d164d0a31 100644
--- a/xbmc-xrandr.c
+++ b/xbmc-xrandr.c
@@ -3005,9 +3005,9 @@ main (int argc, char **argv)
if (mode)
{
if (crtc_info) {
- printf (" w=\"%d\" h=\"%d\" x=\"%d\" y=\"%d\"",
+ printf (" w=\"%d\" h=\"%d\" x=\"%d\" y=\"%d\" crtc=\"%d\"",
crtc_info->width, crtc_info->height,
- crtc_info->x, crtc_info->y);
+ crtc_info->x, crtc_info->y, crtc->crtc.index);
} else {
printf (" w=\"%d\" h=\"%d\" x=\"%d\" y=\"%d\"",
mode->width, mode->height, output->x, output->y);
diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp
index e5fa05aef8..83ad7df098 100644
--- a/xbmc/windowing/X11/WinSystemX11.cpp
+++ b/xbmc/windowing/X11/WinSystemX11.cpp
@@ -217,10 +217,13 @@ bool CWinSystemX11::ResizeWindow(int newWidth, int newHeight, int newLeft, int n
}
}
- if(m_nWidth == newWidth
- && m_nHeight == newHeight
- && m_userOutput.compare(m_currentOutput) == 0)
+ if(m_nWidth == newWidth &&
+ m_nHeight == newHeight &&
+ m_userOutput.compare(m_currentOutput) == 0)
+ {
+ UpdateCrtc();
return true;
+ }
if (!SetWindow(newWidth, newHeight, false, m_userOutput))
{
@@ -1232,6 +1235,8 @@ bool CWinSystemX11::SetWindow(int width, int height, bool fullscreen, const std:
#endif
}
+ UpdateCrtc();
+
return true;
}
@@ -1423,4 +1428,16 @@ bool CWinSystemX11::HasWindowManager()
return true;
}
+void CWinSystemX11::UpdateCrtc()
+{
+ XWindowAttributes winattr;
+ int posx, posy;
+ Window child;
+ XGetWindowAttributes(m_dpy, m_mainWindow, &winattr);
+ XTranslateCoordinates(m_dpy, m_mainWindow, RootWindow(m_dpy, m_nScreen), winattr.x, winattr.y,
+ &posx, &posy, &child);
+
+ m_crtc = g_xrandr.GetCrtc(posx+winattr.width/2, posy+winattr.height/2);
+}
+
#endif
diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h
index 35ae99fbef..d15655482d 100644
--- a/xbmc/windowing/X11/WinSystemX11.h
+++ b/xbmc/windowing/X11/WinSystemX11.h
@@ -87,6 +87,7 @@ public:
void GetConnectedOutputs(std::vector<CStdString> *outputs);
bool IsCurrentOutput(CStdString output);
void RecreateWindow();
+ int GetCrtc() { return m_crtc; }
protected:
bool RefreshGlxContext(bool force);
@@ -118,12 +119,14 @@ protected:
bool m_bIsInternalXrr;
bool m_newGlContext;
int m_MouseX, m_MouseY;
+ int m_crtc;
private:
bool IsSuitableVisual(XVisualInfo *vInfo);
static int XErrorHandler(Display* dpy, XErrorEvent* error);
bool CreateIconPixmap();
bool HasWindowManager();
+ void UpdateCrtc();
CStopWatch m_screensaverReset;
};
diff --git a/xbmc/windowing/X11/XRandR.cpp b/xbmc/windowing/X11/XRandR.cpp
index 3102f3d5ac..d9d7a8fb1c 100644
--- a/xbmc/windowing/X11/XRandR.cpp
+++ b/xbmc/windowing/X11/XRandR.cpp
@@ -117,6 +117,7 @@ bool CXRandR::Query(bool force, int screennum, bool ignoreoff)
xoutput.h = (output->Attribute("h") != NULL ? atoi(output->Attribute("h")) : 0);
xoutput.x = (output->Attribute("x") != NULL ? atoi(output->Attribute("x")) : 0);
xoutput.y = (output->Attribute("y") != NULL ? atoi(output->Attribute("y")) : 0);
+ xoutput.crtc = (output->Attribute("crtc") != NULL ? atoi(output->Attribute("crtc")) : 0);
xoutput.wmm = (output->Attribute("wmm") != NULL ? atoi(output->Attribute("wmm")) : 0);
xoutput.hmm = (output->Attribute("hmm") != NULL ? atoi(output->Attribute("hmm")) : 0);
if (output->Attribute("rotation") != NULL
@@ -477,6 +478,24 @@ XOutput* CXRandR::GetOutput(CStdString outputName)
return result;
}
+int CXRandR::GetCrtc(int x, int y)
+{
+ int crtc = 0;
+ for (unsigned int i = 0; i < m_outputs.size(); ++i)
+ {
+ if (!m_outputs[i].isConnected)
+ continue;
+
+ if ((m_outputs[i].x <= x && (m_outputs[i].x+m_outputs[i].w) > x) &&
+ (m_outputs[i].y <= y && (m_outputs[i].y+m_outputs[i].h) > y))
+ {
+ crtc = m_outputs[i].crtc;
+ break;
+ }
+ }
+ return crtc;
+}
+
CXRandR g_xrandr;
#endif // HAS_XRANDR
diff --git a/xbmc/windowing/X11/XRandR.h b/xbmc/windowing/X11/XRandR.h
index ab7cc63ea6..4538bad7a9 100644
--- a/xbmc/windowing/X11/XRandR.h
+++ b/xbmc/windowing/X11/XRandR.h
@@ -84,6 +84,7 @@ public:
int h;
int x;
int y;
+ int crtc;
int wmm;
int hmm;
std::vector<XMode> modes;
@@ -107,6 +108,7 @@ public:
bool IsOutputConnected(CStdString name);
bool TurnOffOutput(CStdString name);
bool TurnOnOutput(CStdString name);
+ int GetCrtc(int x, int y);
//bool Has1080i();
//bool Has1080p();
//bool Has720p();