aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecIMX.cpp106
-rw-r--r--xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecIMX.h23
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererIMX.cpp2
-rw-r--r--xbmc/windowing/egl/EGLNativeTypeIMX.cpp4
4 files changed, 56 insertions, 79 deletions
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecIMX.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecIMX.cpp
index 4aae4c31c8..b0d3b4e291 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecIMX.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecIMX.cpp
@@ -1227,17 +1227,8 @@ CIMXContext::CIMXContext()
, m_bufferCapture(NULL)
, m_deviceName("/dev/fb1")
{
- m_waitVSync.Reset();
- m_onStartup.Reset();
- m_waitFlip.Reset();
- m_flip.clear();
- m_flip.resize(m_fbPages);
m_pageCrops = new CRectInt[m_fbPages];
- CLog::Log(LOGDEBUG, "iMX : Allocated %d render buffers\n", m_fbPages);
-
- SetBlitRects(CRectInt(), CRectInt());
-
- g2dOpenDevices();
+ OpenDevices();
}
CIMXContext::~CIMXContext()
@@ -1245,29 +1236,16 @@ CIMXContext::~CIMXContext()
Stop(false);
Dispose();
CloseDevices();
- g2dCloseDevices();
}
bool CIMXContext::AdaptScreen(bool allocate)
{
-
- if(m_ipuHandle)
- {
- close(m_ipuHandle);
- m_ipuHandle = 0;
- }
-
MemMap();
- if(!m_fbHandle && !OpenDevices())
- goto Err;
-
struct fb_var_screeninfo fbVar;
if (!GetFBInfo("/dev/fb0", &fbVar))
goto Err;
- CLog::Log(LOGNOTICE, "iMX : Changing framebuffer parameters\n");
-
m_fbWidth = allocate ? 1920 : fbVar.xres;
m_fbHeight = allocate ? 1080 : fbVar.yres;
@@ -1295,6 +1273,7 @@ bool CIMXContext::AdaptScreen(bool allocate)
m_fbVar.yres_virtual = (m_fbVar.yres + 1) * m_fbPages;
m_fbVar.xres_virtual = m_fbVar.xres;
+ CloseIPU();
Blank();
struct fb_fix_screeninfo fb_fix;
@@ -1311,12 +1290,11 @@ bool CIMXContext::AdaptScreen(bool allocate)
}
MemMap(&fb_fix);
-
- if (m_fbVar.bits_per_pixel == 16 || !RENDER_USE_G2D)
- m_ipuHandle = open("/dev/mxc_ipu", O_RDWR, 0);
-
Unblank();
+ OpenIPU();
+ m_bFbIsConfigured = true;
+
return true;
Err:
@@ -1364,13 +1342,15 @@ void CIMXContext::MemMap(struct fb_fix_screeninfo *fb_fix)
void CIMXContext::OnLostDisplay()
{
CSingleLock lk(m_pageSwapLock);
- m_bFbIsConfigured = false;
+ if (IsRunning())
+ m_bFbIsConfigured = false;
}
void CIMXContext::OnResetDisplay()
{
CSingleLock lk(m_pageSwapLock);
- m_bFbIsConfigured = false;
+ if (m_bFbIsConfigured)
+ return;
CLog::Log(LOGDEBUG, "iMX : %s - going to change screen parameters\n", __FUNCTION__);
AdaptScreen();
@@ -1397,32 +1377,30 @@ void CIMXContext::Dispose()
m_pageCrops = NULL;
}
-bool CIMXContext::OpenDevices()
+void CIMXContext::OpenIPU()
{
- m_fbHandle = open(m_deviceName.c_str(), O_RDWR, 0);
- if (m_fbHandle < 0)
- {
- m_fbHandle = 0;
- CLog::Log(LOGWARNING, "iMX : Failed to open framebuffer: %s\n", m_deviceName.c_str());
- }
-
- return m_fbHandle > 0;
+ m_ipuHandle = open("/dev/mxc_ipu", O_RDWR, 0);
}
-void CIMXContext::g2dOpenDevices()
+bool CIMXContext::OpenDevices()
{
- // open g2d here to ensure all g2d fucntions are called from the same thread
- if (!g2d_open(&m_g2dHandle))
- return;
+ m_fbHandle = open(m_deviceName.c_str(), O_RDWR, 0);
+ OpenIPU();
+
+ bool opened = m_fbHandle > 0 && m_ipuHandle > 0;
+ if (!opened)
+ CLog::Log(LOGWARNING, "iMX : Failed to open framebuffer: %s\n", m_deviceName.c_str());
- m_g2dHandle = NULL;
- CLog::Log(LOGERROR, "%s - Error while trying open G2D\n", __FUNCTION__);
+ return opened;
}
-void CIMXContext::g2dCloseDevices()
+void CIMXContext::CloseIPU()
{
- if (m_g2dHandle && !g2d_close(m_g2dHandle))
- m_g2dHandle = NULL;
+ if (m_ipuHandle)
+ {
+ close(m_ipuHandle);
+ m_ipuHandle = 0;
+ }
}
void CIMXContext::CloseDevices()
@@ -1435,11 +1413,7 @@ void CIMXContext::CloseDevices()
m_fbHandle = 0;
}
- if (m_ipuHandle)
- {
- close(m_ipuHandle);
- m_ipuHandle = 0;
- }
+ CloseIPU();
}
bool CIMXContext::Blank()
@@ -1860,6 +1834,13 @@ bool CIMXContext::CaptureDisplay(unsigned char *&buffer, int iWidth, int iHeight
else if (blend)
std::memcpy(m_bufferCapture->buf_vaddr, buffer, m_bufferCapture->buf_size);
+ if (g2d_open(&m_g2dHandle))
+ {
+ CLog::Log(LOGERROR, "%s : Error while trying open G2D\n", __FUNCTION__);
+ return false;
+ }
+
+ CSingleLock lk(m_pageSwapLock);
if (m_bufferCapture && buffer)
{
struct g2d_surface src, dst;
@@ -1905,33 +1886,34 @@ bool CIMXContext::CaptureDisplay(unsigned char *&buffer, int iWidth, int iHeight
std::memcpy(buffer, m_bufferCapture->buf_vaddr, m_bufferCapture->buf_size);
}
else
- {
CLog::Log(LOGERROR, "iMX : Error allocating capture buffer\n");
- }
if (m_bufferCapture && g2d_free(m_bufferCapture))
CLog::Log(LOGERROR, "iMX : Error while freeing capture buuffer\n");
+ if (m_g2dHandle && !g2d_close(m_g2dHandle))
+ m_g2dHandle = NULL;
return true;
}
-void CIMXContext::OnStartup()
+void CIMXContext::Allocate()
{
- g_Windowing.Register(this);
-
CSingleLock lk(m_pageSwapLock);
-
- OpenDevices();
-
AdaptScreen(true);
AdaptScreen();
+ Create();
+}
- m_onStartup.Set();
+void CIMXContext::OnStartup()
+{
+ CSingleLock lk(m_pageSwapLock);
+ g_Windowing.Register(this);
CLog::Log(LOGNOTICE, "iMX : IPU thread started");
}
void CIMXContext::OnExit()
{
+ CSingleLock lk(m_pageSwapLock);
g_Windowing.Unregister(this);
CLog::Log(LOGNOTICE, "iMX : IPU thread terminated");
}
@@ -1942,7 +1924,7 @@ void CIMXContext::Stop(bool bWait /*= true*/)
return;
CThread::StopThread(false);
- Blank();
+ m_pingFlip.Set();
if (bWait && IsRunning())
CThread::StopThread(true);
}
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecIMX.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecIMX.h
index bde21acff9..6375cc9ef2 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecIMX.h
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecIMX.h
@@ -102,15 +102,18 @@ public:
bool AdaptScreen(bool allocate = false);
bool TaskRestart();
+ void OpenIPU();
+ void CloseIPU();
void CloseDevices();
- void g2dCloseDevices();
- void g2dOpenDevices();
bool OpenDevices();
bool Blank();
bool Unblank();
bool SetVSync(bool enable);
+ void WaitVSync();
+ void Stop(bool bWait = true);
+
// Blitter configuration
bool IsDoubleRate() const { return m_currentFieldFmt & IPU_DEINTERLACE_RATE_EN; }
void SetVideoPixelFormat(CProcessInfo *m_pProcessInfo);
@@ -125,7 +128,6 @@ public:
// Shows a page vsynced
bool ShowPage();
- void WaitVSync();
// Clears the pages or a single page with 'black'
void Clear(int page = RENDER_TASK_AUTOPAGE);
@@ -137,7 +139,7 @@ public:
void OnResetDisplay();
void OnLostDisplay();
- void create() { Create(); m_onStartup.Wait(); }
+ void Allocate();
static const int m_fbPages;
@@ -179,16 +181,12 @@ private:
void Dispose();
void MemMap(struct fb_fix_screeninfo *fb_fix = NULL);
- void Stop(bool bWait = true);
- virtual void OnStartup();
- virtual void OnExit();
- virtual void Process();
+ virtual void OnStartup() override;
+ virtual void OnExit() override;
+ virtual void Process() override;
private:
- lkFIFO<IPUTaskPtr> m_input;
- std::vector<bool> m_flip;
-
int m_fbHandle;
std::atomic<int> m_fbCurrentPage;
int m_pg;
@@ -208,8 +206,7 @@ private:
CRectInt *m_pageCrops;
bool m_bFbIsConfigured;
CEvent m_waitVSync;
- CEvent m_onStartup;
- CEvent m_waitFlip;
+ CEvent m_pingFlip;
CProcessInfo *m_processInfo;
CCriticalSection m_pageSwapLock;
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererIMX.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererIMX.cpp
index 73fc32331c..6123110e32 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererIMX.cpp
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererIMX.cpp
@@ -35,14 +35,12 @@
CRendererIMX::CRendererIMX()
{
m_bufHistory.clear();
- g_IMXContext.Clear();
}
CRendererIMX::~CRendererIMX()
{
UnInit();
std::for_each(m_bufHistory.begin(), m_bufHistory.end(), Release);
- g_IMXContext.Clear();
g_IMX.Deinitialize();
}
diff --git a/xbmc/windowing/egl/EGLNativeTypeIMX.cpp b/xbmc/windowing/egl/EGLNativeTypeIMX.cpp
index d8c09830fd..5c8555660d 100644
--- a/xbmc/windowing/egl/EGLNativeTypeIMX.cpp
+++ b/xbmc/windowing/egl/EGLNativeTypeIMX.cpp
@@ -128,10 +128,10 @@ void CEGLNativeTypeIMX::Initialize()
CLog::Log(LOGERROR, "%s - Failed to setup color keying\n", __FUNCTION__);
close(fd);
+ ShowWindow(true);
+ g_IMXContext.Allocate();
m_sar = GetMonitorSAR();
- g_IMXContext.create();
- ShowWindow(true);
#endif
return;
}