From e46e3adff3ef50e536d4220f1bb654b5a6f7f98c Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Fri, 21 Feb 2014 23:22:52 +0100 Subject: [PATCH] projects/Cuboxi/patches/xbmc: update IMX patch Signed-off-by: Stephan Raue --- .../patches/xbmc/xbmc-001-imx6_support.patch | 577 ++++++++++-------- 1 file changed, 311 insertions(+), 266 deletions(-) diff --git a/projects/Cuboxi/patches/xbmc/xbmc-001-imx6_support.patch b/projects/Cuboxi/patches/xbmc/xbmc-001-imx6_support.patch index 4e7f6c9b7f..c2c986823a 100644 --- a/projects/Cuboxi/patches/xbmc/xbmc-001-imx6_support.patch +++ b/projects/Cuboxi/patches/xbmc/xbmc-001-imx6_support.patch @@ -1,6 +1,6 @@ -diff -Naur xbmc-gotham-latest.test/configure.in xbmc-imx6.test/configure.in ---- xbmc-gotham-latest.test/configure.in 2014-02-19 22:25:08.062516204 +0100 -+++ xbmc-imx6.test/configure.in 2014-02-19 22:25:22.740529992 +0100 +diff -Naur xbmc-gotham-latest.test/configure.in xbmc-imx6-koying.test/configure.in +--- xbmc-gotham-latest.test/configure.in 2014-02-21 23:10:49.246106103 +0100 ++++ xbmc-imx6-koying.test/configure.in 2014-02-21 23:11:24.639122704 +0100 @@ -558,7 +558,7 @@ AC_ARG_ENABLE([codec], @@ -28,9 +28,9 @@ diff -Naur xbmc-gotham-latest.test/configure.in xbmc-imx6.test/configure.in *) esac done -diff -Naur xbmc-gotham-latest.test/lib/ffmpeg/libavcodec/arm/dca.h xbmc-imx6.test/lib/ffmpeg/libavcodec/arm/dca.h ---- xbmc-gotham-latest.test/lib/ffmpeg/libavcodec/arm/dca.h 2014-02-19 22:24:57.603506380 +0100 -+++ xbmc-imx6.test/lib/ffmpeg/libavcodec/arm/dca.h 2014-02-19 22:25:22.019529315 +0100 +diff -Naur xbmc-gotham-latest.test/lib/ffmpeg/libavcodec/arm/dca.h xbmc-imx6-koying.test/lib/ffmpeg/libavcodec/arm/dca.h +--- xbmc-gotham-latest.test/lib/ffmpeg/libavcodec/arm/dca.h 2014-02-21 23:10:38.903101147 +0100 ++++ xbmc-imx6-koying.test/lib/ffmpeg/libavcodec/arm/dca.h 2014-02-21 23:11:24.183122503 +0100 @@ -30,9 +30,9 @@ #define decode_blockcodes decode_blockcodes @@ -48,9 +48,9 @@ diff -Naur xbmc-gotham-latest.test/lib/ffmpeg/libavcodec/arm/dca.h xbmc-imx6.tes #endif /* AVCODEC_ARM_DCA_H */ + -diff -Naur xbmc-gotham-latest.test/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp xbmc-imx6.test/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp ---- xbmc-gotham-latest.test/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp 2014-02-19 22:24:45.699495198 +0100 -+++ xbmc-imx6.test/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp 2014-02-19 22:25:21.467528797 +0100 +diff -Naur xbmc-gotham-latest.test/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp xbmc-imx6-koying.test/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp +--- xbmc-gotham-latest.test/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp 2014-02-21 23:10:30.558097110 +0100 ++++ xbmc-imx6-koying.test/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp 2014-02-21 23:11:23.795122326 +0100 @@ -714,7 +714,10 @@ * will automatically add "@" instead to enable surroundXX mangling. * We don't want to do that if "default" can handle multichannel @@ -96,9 +96,9 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp x if (name.substr(0, 4) == "hdmi") return AE_DEVTYPE_HDMI; else if (name.substr(0, 6) == "iec958" || name.substr(0, 5) == "spdif") -diff -Naur xbmc-gotham-latest.test/xbmc/cores/AudioEngine/Utils/AEConvert.cpp xbmc-imx6.test/xbmc/cores/AudioEngine/Utils/AEConvert.cpp ---- xbmc-gotham-latest.test/xbmc/cores/AudioEngine/Utils/AEConvert.cpp 2014-02-19 22:24:45.727495224 +0100 -+++ xbmc-imx6.test/xbmc/cores/AudioEngine/Utils/AEConvert.cpp 2014-02-19 22:25:21.467528797 +0100 +diff -Naur xbmc-gotham-latest.test/xbmc/cores/AudioEngine/Utils/AEConvert.cpp xbmc-imx6-koying.test/xbmc/cores/AudioEngine/Utils/AEConvert.cpp +--- xbmc-gotham-latest.test/xbmc/cores/AudioEngine/Utils/AEConvert.cpp 2014-02-21 23:10:30.595097127 +0100 ++++ xbmc-imx6-koying.test/xbmc/cores/AudioEngine/Utils/AEConvert.cpp 2014-02-21 23:11:23.796122326 +0100 @@ -841,7 +841,7 @@ _mm_empty(); #else /* no SSE2 */ @@ -108,9 +108,9 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/AudioEngine/Utils/AEConvert.cpp xb #endif return samples << 2; -diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp xbmc-imx6.test/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp ---- xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp 2014-02-19 22:24:45.330494851 +0100 -+++ xbmc-imx6.test/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp 2014-02-19 22:25:21.443528774 +0100 +diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp xbmc-imx6-koying.test/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp +--- xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp 2014-02-21 23:10:30.378097022 +0100 ++++ xbmc-imx6-koying.test/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp 2014-02-21 23:11:23.790122324 +0100 @@ -35,6 +35,9 @@ #include "Video/DVDVideoCodecFFmpeg.h" #include "Video/DVDVideoCodecOpenMax.h" @@ -121,7 +121,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCode #include "Video/DVDVideoCodecStageFright.h" #if defined(HAVE_LIBCRYSTALHD) #include "Video/DVDVideoCodecCrystalHD.h" -@@ -194,7 +197,11 @@ +@@ -191,7 +194,11 @@ #elif defined(TARGET_POSIX) && !defined(TARGET_DARWIN) hwSupport += "VAAPI:no "; #endif @@ -134,7 +134,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCode CLog::Log(LOGDEBUG, "CDVDFactoryCodec: compiled in hardware support: %s", hwSupport.c_str()); #if defined(HAS_LIBAMCODEC) // amcodec can handle dvd playback. -@@ -208,6 +215,15 @@ +@@ -205,6 +212,15 @@ } } @@ -150,9 +150,9 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCode #if defined(TARGET_DARWIN_OSX) if (!hint.software && CSettings::Get().GetBool("videoplayer.usevda")) { -diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h xbmc-imx6.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h ---- xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h 2014-02-19 22:24:45.337494858 +0100 -+++ xbmc-imx6.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h 2014-02-19 22:25:21.443528774 +0100 +diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h xbmc-imx6-koying.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h +--- xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h 2014-02-21 23:10:30.397097031 +0100 ++++ xbmc-imx6-koying.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h 2014-02-21 23:11:23.790122324 +0100 @@ -27,6 +27,7 @@ #include #include @@ -173,10 +173,10 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo }; unsigned int iFlags; -diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecIMX.cpp xbmc-imx6.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecIMX.cpp +diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecIMX.cpp xbmc-imx6-koying.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecIMX.cpp --- xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecIMX.cpp 1970-01-01 01:00:00.000000000 +0100 -+++ xbmc-imx6.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecIMX.cpp 2014-02-19 22:25:21.444528775 +0100 -@@ -0,0 +1,979 @@ ++++ xbmc-imx6-koying.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecIMX.cpp 2014-02-21 23:11:23.790122324 +0100 +@@ -0,0 +1,950 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://www.xbmc.org @@ -276,8 +276,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + +int CDVDVideoCodecIMX::VpuFindBuffer(void *frameAddr) +{ -+ int i; -+ for (i=0; i1) + { + ptr=(unsigned char*)Align(ptr,nAlign); + ptrVirt=(unsigned char*)Align(ptrVirt,nAlign); + } + -+ /* fill stride info */ ++ // fill stride info + m_vpuFrameBuffers[i].nStrideY=yStride; + m_vpuFrameBuffers[i].nStrideC=uvStride; + -+ /* fill phy addr*/ ++ // fill phy addr + m_vpuFrameBuffers[i].pbufY=ptr; + m_vpuFrameBuffers[i].pbufCb=ptr+ySize; + m_vpuFrameBuffers[i].pbufCr=0; + m_vpuFrameBuffers[i].pbufMvCol=ptr+ySize+uvSize; + //ptr+=ySize+uSize+vSize+mvSize; -+ /* fill virt addr */ ++ // fill virt addr + m_vpuFrameBuffers[i].pbufVirtY=ptrVirt; + m_vpuFrameBuffers[i].pbufVirtCb=ptrVirt+ySize; + m_vpuFrameBuffers[i].pbufVirtCr=0; @@ -498,7 +495,6 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + m_outputBuffers = NULL; + m_extraMem = NULL; + m_vpuFrameBufferNum = 0; -+ m_tsSyncRequired = true; + m_dropState = false; + m_convert_bitstream = false; + m_frameCounter = 0; @@ -542,10 +538,9 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + } + if (m_hints.extrasize) + { -+ unsigned int i; + char buf[4096]; + -+ for (i = 0; i < m_hints.extrasize; i++) ++ for (int i=0; i < m_hints.extrasize; i++) + sprintf(buf+i*2, "%02x", ((uint8_t*)m_hints.extradata)[i]); + CLog::Log(LOGDEBUG, "Decode: MEDIAINFO: extradata %d %s\n", m_hints.extrasize, buf); + } @@ -608,19 +603,19 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + m_pFormatName = "iMX-vp8"; + break; + case CODEC_ID_MSMPEG4V3: -+ m_decOpenParam.CodecFormat = VPU_V_XVID; /* VPU_V_DIVX3 */ ++ m_decOpenParam.CodecFormat = VPU_V_XVID; // VPU_V_DIVX3 + m_pFormatName = "iMX-divx3"; + break; + case CODEC_ID_MPEG4: + switch(m_hints.codec_tag) + { + case _4CC('D','I','V','X'): -+ m_decOpenParam.CodecFormat = VPU_V_XVID; /* VPU_V_DIVX4 */ ++ m_decOpenParam.CodecFormat = VPU_V_XVID; // VPU_V_DIVX4 + m_pFormatName = "iMX-divx4"; + break; + case _4CC('D','X','5','0'): + case _4CC('D','I','V','5'): -+ m_decOpenParam.CodecFormat = VPU_V_XVID; /* VPU_V_DIVX56 */ ++ m_decOpenParam.CodecFormat = VPU_V_XVID; // VPU_V_DIVX56 + m_pFormatName = "iMX-divx5"; + break; + case _4CC('X','V','I','D'): @@ -647,12 +642,11 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo +{ + VpuDecRetCode ret; + bool VPU_loaded = m_vpuHandle; -+ int i; + + // Invalidate output buffers to prevent the renderer from mapping this memory -+ for (i=0; iInvalidate(&m_vpuHandle); ++ m_outputBuffers[i]->ReleaseFramebuffer(&m_vpuHandle); + SAFE_RELEASE(m_outputBuffers[i]); + } + @@ -671,6 +665,10 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + m_vpuHandle = 0; + } + ++ // Clear pts queue ++ while(!m_pts.empty()) ++ m_pts.pop(); ++ + // Clear memory + if (m_outputBuffers != NULL) + { @@ -709,12 +707,11 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + VpuDecFrameLengthInfo frameLengthInfo; + VpuBufferNode inData; + VpuDecRetCode ret; -+ int decRet = 0, i; ++ int decRet = 0; + int retStatus = 0; + int demuxer_bytes = iSize; + uint8_t *demuxer_content = pData; + bool retry = false; -+ int idx; + +#ifdef IMX_PROFILE + static unsigned long long previous, current; @@ -728,11 +725,11 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + return VC_ERROR; + } + -+ for (i=0; i < m_vpuFrameBufferNum; i++) ++ for (int i=0; i < m_vpuFrameBufferNum; i++) + { + if (m_outputBuffers[i]->Rendered()) + { -+ ret = m_outputBuffers[i]->ClearDisplay(&m_vpuHandle); ++ ret = m_outputBuffers[i]->ReleaseFramebuffer(&m_vpuHandle); + if(ret != VPU_DEC_RET_SUCCESS) + { + CLog::Log(LOGERROR, "%s: vpu clear frame display failure: ret=%d \r\n",__FUNCTION__,ret); @@ -765,10 +762,18 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + CLog::Log(LOGERROR,"%s - bitstream_convert error", __FUNCTION__); + } + ++ if (m_usePTS) ++ { ++ if (pts != DVD_NOPTS_VALUE) ++ m_pts.push(-pts); ++ else if (dts != DVD_NOPTS_VALUE) ++ m_pts.push(-dts); ++ } ++ + inData.nSize = demuxer_bytes; + inData.pPhyAddr = NULL; + inData.pVirAddr = demuxer_content; -+ /* FIXME TODO VP8 & DivX3 require specific sCodecData values */ ++ // FIXME TODO VP8 & DivX3 require specific sCodecData values + if ((m_decOpenParam.CodecFormat == VPU_V_MPEG2) || + (m_decOpenParam.CodecFormat == VPU_V_VC1_AP)|| + (m_decOpenParam.CodecFormat == VPU_V_XVID)) @@ -800,7 +805,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + } + + if (decRet & VPU_DEC_INIT_OK) -+ /* VPU decoding init OK : We can retrieve stream info */ ++ // VPU decoding init OK : We can retrieve stream info + { + ret = VPU_DecGetInitialInfo(m_vpuHandle, &m_initInfo); + if (ret == VPU_DEC_RET_SUCCESS) @@ -829,39 +834,18 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + CLog::Log(LOGERROR, "%s - VPU get initial info failed (%d).\n", __FUNCTION__, ret); + goto out_error; + } -+ }//VPU_DEC_INIT_OK ++ } //VPU_DEC_INIT_OK + + if (decRet & VPU_DEC_ONE_FRM_CONSUMED) + { + ret = VPU_DecGetConsumedFrameInfo(m_vpuHandle, &frameLengthInfo); + if (ret != VPU_DEC_RET_SUCCESS) -+ { + CLog::Log(LOGERROR, "%s - VPU error retireving info about consummed frame (%d).\n", __FUNCTION__, ret); -+ } -+ if (frameLengthInfo.pFrame) -+ { -+ idx = VpuFindBuffer(frameLengthInfo.pFrame->pbufY); -+ if (idx != -1) -+ { -+ if (pts != DVD_NOPTS_VALUE) -+ { -+ m_outputBuffers[idx]->SetPts(pts); -+ } -+ else if (dts != DVD_NOPTS_VALUE) -+ { -+ m_outputBuffers[idx]->SetPts(dts); -+ } -+ } -+ else -+ { -+ CLog::Log(LOGERROR, "%s - could not find frame buffer\n", __FUNCTION__); -+ } -+ } -+ }//VPU_DEC_ONE_FRM_CONSUMED ++ } //VPU_DEC_ONE_FRM_CONSUMED + + if ((decRet & VPU_DEC_OUTPUT_DIS) || + (decRet & VPU_DEC_OUTPUT_MOSAIC_DIS)) -+ /* Frame ready to be displayed */ ++ // Frame ready to be displayed + { + if (retStatus & VC_PICTURE) + CLog::Log(LOGERROR, "%s - Second picture in the same decode call !\n", __FUNCTION__); @@ -918,9 +902,9 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + if (!(decRet & VPU_DEC_OUTPUT_DIS) && + (inData.nSize != 0)) + { -+ /* Let's process again as VPU_DEC_NO_ENOUGH_INBUF was not set -+ * and we don't have an image ready if we reach that point -+ */ ++ // Let's process again as VPU_DEC_NO_ENOUGH_INBUF was not set ++ // and we don't have an image ready if we reach that point ++ + inData.pVirAddr = NULL; + inData.nSize = 0; + retry = true; @@ -945,18 +929,19 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + +void CDVDVideoCodecIMX::Reset() +{ -+ int ret, i; ++ int ret; + + CLog::Log(LOGDEBUG, "%s - called\n", __FUNCTION__); + -+ /* We have to resync timestamp manager */ -+ m_tsSyncRequired = true; ++ // Clear pts queue ++ while(!m_pts.empty()) ++ m_pts.pop(); + -+ /* Invalidate all buffers */ -+ for(i = 0; i < m_vpuFrameBufferNum; i++) -+ m_outputBuffers[i]->Invalidate(&m_vpuHandle); ++ // Invalidate all buffers ++ for(int i=0; i < m_vpuFrameBufferNum; i++) ++ m_outputBuffers[i]->ReleaseFramebuffer(&m_vpuHandle); + -+ /* Flush VPU */ ++ // Flush VPU + ret = VPU_DecFlushAll(m_vpuHandle); + if (ret != VPU_DEC_RET_SUCCESS) + { @@ -989,6 +974,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + pDvdVideoPicture->iFlags &= ~DVP_FLAG_DROPPED; + + pDvdVideoPicture->format = RENDER_FMT_IMXMAP; ++ pDvdVideoPicture->pts = DVD_NOPTS_VALUE; + pDvdVideoPicture->dts = DVD_NOPTS_VALUE; + pDvdVideoPicture->iWidth = m_frameInfo.pExtInfo->FrmCropRect.nRight - m_frameInfo.pExtInfo->FrmCropRect.nLeft; + pDvdVideoPicture->iHeight = m_frameInfo.pExtInfo->FrmCropRect.nBottom - m_frameInfo.pExtInfo->FrmCropRect.nTop; @@ -1000,11 +986,17 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + if (idx != -1) + { + CDVDVideoCodecIMXBuffer *buffer = m_outputBuffers[idx]; -+ pDvdVideoPicture->pts = buffer->GetPts(); -+ if (!m_usePTS) ++ if (m_usePTS) + { -+ pDvdVideoPicture->pts = DVD_NOPTS_VALUE; ++ if (m_pts.size()) ++ { ++ pDvdVideoPicture->pts = -m_pts.top(); ++ m_pts.pop(); ++ } ++ else ++ CLog::Log(LOGERROR, "%s - logic error: no PTS available", __FUNCTION__); + } ++ + buffer->Queue(m_frameInfo.pDisplayFrameBuf); + pDvdVideoPicture->codecinfo = buffer; + @@ -1030,10 +1022,10 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo +void CDVDVideoCodecIMX::SetDropState(bool bDrop) +{ + -+ /* We are fast enough to continue to really decode every frames -+ * and avoid artefacts... -+ * (Of course these frames won't be rendered but only decoded !) -+ */ ++ // We are fast enough to continue to really decode every frames ++ // and avoid artefacts... ++ // (Of course these frames won't be rendered but only decoded !) ++ + if (m_dropState != bDrop) + { + m_dropState = bDrop; @@ -1053,7 +1045,6 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo +#endif + , m_frameBuffer(NULL) + , m_rendered(false) -+ , m_pts(DVD_NOPTS_VALUE) +{ +} + @@ -1101,24 +1092,6 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + return m_frameBuffer != NULL; +} + -+void CDVDVideoCodecIMXBuffer::Invalidate(VpuDecHandle *handle) -+{ -+ CSingleLock lock(CDVDVideoCodecIMX::m_codecBufferLock); -+#ifdef TRACE_FRAMES -+ CLog::Log(LOGDEBUG, "I %02d\n", m_idx); -+#endif -+ if((m_frameBuffer != NULL) && *handle) -+ { -+ VpuDecRetCode ret = VPU_DecOutFrameDisplayed(*handle, m_frameBuffer); -+ if(ret != VPU_DEC_RET_SUCCESS) -+ CLog::Log(LOGERROR, "%s: vpu clear frame display failure: ret=%d \r\n",__FUNCTION__,ret); -+ } -+ -+ m_frameBuffer = NULL; -+ m_rendered = false; -+ m_pts = DVD_NOPTS_VALUE; -+} -+ +bool CDVDVideoCodecIMXBuffer::Rendered() +{ + return m_rendered; @@ -1126,40 +1099,38 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + +void CDVDVideoCodecIMXBuffer::Queue(VpuFrameBuffer *buffer) +{ ++ CSingleLock lock(CDVDVideoCodecIMX::m_codecBufferLock); + m_frameBuffer = buffer; + m_rendered = false; +} + -+VpuDecRetCode CDVDVideoCodecIMXBuffer::ClearDisplay(VpuDecHandle *handle) ++VpuDecRetCode CDVDVideoCodecIMXBuffer::ReleaseFramebuffer(VpuDecHandle *handle) +{ -+ VpuDecRetCode ret = VPU_DecOutFrameDisplayed(*handle, m_frameBuffer); ++ CSingleLock lock(CDVDVideoCodecIMX::m_codecBufferLock); ++ VpuDecRetCode ret = VPU_DEC_RET_FAILURE; ++ ++ if((m_frameBuffer != NULL) && *handle) ++ { ++ ret = VPU_DecOutFrameDisplayed(*handle, m_frameBuffer); ++ if(ret != VPU_DEC_RET_SUCCESS) ++ CLog::Log(LOGERROR, "%s: vpu clear frame display failure: ret=%d \r\n",__FUNCTION__,ret); ++ } +#ifdef TRACE_FRAMES + CLog::Log(LOGDEBUG, "- %02d\n", m_idx); +#endif + m_rendered = false; + m_frameBuffer = NULL; -+ m_pts = DVD_NOPTS_VALUE; + return ret; +} + -+void CDVDVideoCodecIMXBuffer::SetPts(double pts) -+{ -+ m_pts = pts; -+} -+ -+double CDVDVideoCodecIMXBuffer::GetPts(void) const -+{ -+ return m_pts; -+} -+ +CDVDVideoCodecIMXBuffer::~CDVDVideoCodecIMXBuffer() +{ + assert(m_refs == 0); +} -diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecIMX.h xbmc-imx6.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecIMX.h +diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecIMX.h xbmc-imx6-koying.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecIMX.h --- xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecIMX.h 1970-01-01 01:00:00.000000000 +0100 -+++ xbmc-imx6.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecIMX.h 2014-02-19 22:25:21.444528775 +0100 -@@ -0,0 +1,132 @@ ++++ xbmc-imx6-koying.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecIMX.h 2014-02-21 23:11:23.791122324 +0100 +@@ -0,0 +1,129 @@ +#pragma once +/* + * Copyright (C) 2010-2013 Team XBMC @@ -1189,11 +1160,12 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo +#include "threads/CriticalSection.h" +#include "utils/BitstreamConverter.h" + ++#include + +//#define IMX_PROFILE +//#define TRACE_FRAMES + -+/* FIXME TODO Develop real proper CVPUBuffer class */ ++// FIXME TODO Develop real proper CVPUBuffer class +#define VPU_DEC_MAX_NUM_MEM_NUM 20 +typedef struct +{ @@ -1223,12 +1195,9 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + virtual long Release(); + virtual bool IsValid(); + -+ void Invalidate(VpuDecHandle *handle); + bool Rendered(); + void Queue(VpuFrameBuffer *buffer); -+ VpuDecRetCode ClearDisplay(VpuDecHandle *handle); -+ void SetPts(double pts); -+ double GetPts(void) const; ++ VpuDecRetCode ReleaseFramebuffer(VpuDecHandle *handle); + +protected: + // private because we are reference counted @@ -1240,7 +1209,6 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + long m_refs; + VpuFrameBuffer *m_frameBuffer; + bool m_rendered; -+ double m_pts; +}; + +class CDVDVideoCodecIMX : public CDVDVideoCodec @@ -1279,7 +1247,6 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo + DecMemInfo m_decMemInfo; // VPU dedicated memory description + VpuDecHandle m_vpuHandle; // Handle for VPU library calls + VpuDecInitInfo m_initInfo; // Initial info returned from VPU at decoding start -+ bool m_tsSyncRequired; // state whether timestamp manager has to be sync'ed + bool m_dropState; // Current drop state + int m_vpuFrameBufferNum; // Total number of allocated frame buffers + VpuFrameBuffer *m_vpuFrameBuffers; // Table of VPU frame buffers description @@ -1288,13 +1255,14 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo +// VpuMemDesc *m_outputBuffers; // Table of buffers out of VPU (used to call properly VPU_DecOutFrameDisplayed) + int m_frameCounter; // Decoded frames counter + bool m_usePTS; // State whether pts out of decoding process should be used ++ std::priority_queue m_pts; + VpuDecOutFrameInfo m_frameInfo; + CBitstreamConverter *m_converter; + bool m_convert_bitstream; +}; -diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecInfo.h xbmc-imx6.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecInfo.h +diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecInfo.h xbmc-imx6-koying.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecInfo.h --- xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecInfo.h 1970-01-01 01:00:00.000000000 +0100 -+++ xbmc-imx6.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecInfo.h 2014-02-19 22:25:21.444528775 +0100 ++++ xbmc-imx6-koying.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecInfo.h 2014-02-21 23:11:23.791122324 +0100 @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010-2013 Team XBMC @@ -1334,9 +1302,9 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideo +}; + +#endif // DVDVIDEOCODECINFO_H -diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in xbmc-imx6.test/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in ---- xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in 2014-02-19 22:24:45.332494853 +0100 -+++ xbmc-imx6.test/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in 2014-02-19 22:25:21.443528774 +0100 +diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in xbmc-imx6-koying.test/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in +--- xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in 2014-02-21 23:10:30.382097024 +0100 ++++ xbmc-imx6-koying.test/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in 2014-02-21 23:11:23.790122324 +0100 @@ -24,6 +24,9 @@ SRCS += OpenMaxVideo.cpp SRCS += DVDVideoCodecOpenMax.cpp @@ -1347,9 +1315,9 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile ifeq (@USE_LIBAMCODEC@,1) SRCS += AMLCodec.cpp SRCS += DVDVideoCodecAmlogic.cpp -diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp xbmc-imx6.test/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp ---- xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2014-02-19 22:24:45.653495155 +0100 -+++ xbmc-imx6.test/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2014-02-19 22:25:21.465528794 +0100 +diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp xbmc-imx6-koying.test/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp +--- xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2014-02-21 23:10:30.530097095 +0100 ++++ xbmc-imx6-koying.test/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2014-02-21 23:11:23.794122325 +0100 @@ -995,6 +995,8 @@ case RENDER_FMT_EGLIMG: return "EGLIMG"; case RENDER_FMT_BYPASS: return "BYPASS"; @@ -1359,27 +1327,20 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp xbmc- case RENDER_FMT_NONE: return "NONE"; } return "UNKNOWN"; -diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp xbmc-imx6.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp ---- xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp 2014-02-19 22:24:45.278494803 +0100 -+++ xbmc-imx6.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp 2014-02-19 22:25:21.442528773 +0100 -@@ -26,6 +26,9 @@ - #endif - - #if HAS_GLES == 2 -+#ifdef HAS_IMXVPU -+#define GL_GLEXT_PROTOTYPES -+#endif - #include "system_gl.h" - - #include -@@ -76,6 +79,12 @@ +diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp xbmc-imx6-koying.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp +--- xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp 2014-02-21 23:10:30.329096998 +0100 ++++ xbmc-imx6-koying.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp 2014-02-21 23:11:23.788122322 +0100 +@@ -76,6 +76,15 @@ static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; #endif +#ifdef HAS_IMXVPU -+// GLES extension functions -+#include -+#include ++#include "windowing/egl/EGLWrapper.h" ++#define GL_VIV_NV12 0x8FC1 ++typedef void (GL_APIENTRYP PFNGLTEXDIRECTVIVMAPPROC) (GLenum Target, GLsizei Width, GLsizei Height, GLenum Format, GLvoid ** Logical, const GLuint * Physical); ++typedef void (GL_APIENTRYP PFNGLTEXDIRECTINVALIDATEVIVPROC) (GLenum Target); ++static PFNGLTEXDIRECTVIVMAPPROC glTexDirectVIVMap; ++static PFNGLTEXDIRECTINVALIDATEVIVPROC glTexDirectInvalidateVIV; +#endif + #if defined(TARGET_ANDROID) @@ -1393,7 +1354,20 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.c } CLinuxRendererGLES::YUVBUFFER::~YUVBUFFER() -@@ -279,6 +289,10 @@ +@@ -151,6 +161,12 @@ + if (!glEGLImageTargetTexture2DOES) + glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) CEGLWrapper::GetProcAddress("glEGLImageTargetTexture2DOES"); + #endif ++#ifdef HAS_IMXVPU ++ if (!glTexDirectVIVMap) ++ glTexDirectVIVMap = (PFNGLTEXDIRECTVIVMAPPROC) CEGLWrapper::GetProcAddress("glTexDirectVIVMap"); ++ if (!glTexDirectInvalidateVIV) ++ glTexDirectInvalidateVIV = (PFNGLTEXDIRECTINVALIDATEVIVPROC) CEGLWrapper::GetProcAddress("glTexDirectInvalidateVIV"); ++#endif + } + + CLinuxRendererGLES::~CLinuxRendererGLES() +@@ -279,6 +295,10 @@ { return source; } @@ -1404,7 +1378,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.c #ifdef HAVE_VIDEOTOOLBOXDECODER if (m_renderMethod & RENDER_CVREF ) -@@ -604,6 +618,10 @@ +@@ -604,6 +624,10 @@ #if defined(TARGET_ANDROID) m_formats.push_back(RENDER_FMT_MEDIACODEC); #endif @@ -1415,7 +1389,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.c // setup the background colour m_clearColour = (float)(g_advancedSettings.m_videoBlackBarColour & 0xff) / 0xff; -@@ -715,6 +733,16 @@ +@@ -715,6 +739,16 @@ m_renderMethod = RENDER_MEDIACODEC; break; } @@ -1432,7 +1406,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.c else if (m_format == RENDER_FMT_BYPASS) { CLog::Log(LOGNOTICE, "GL: Using BYPASS render method"); -@@ -807,6 +835,18 @@ +@@ -807,6 +841,18 @@ m_textureCreate = &CLinuxRendererGLES::CreateNV12Texture; m_textureDelete = &CLinuxRendererGLES::DeleteNV12Texture; } @@ -1451,7 +1425,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.c else { // default to YV12 texture handlers -@@ -952,6 +992,10 @@ +@@ -952,6 +998,10 @@ { RenderSurfaceTexture(index, m_currentField); } @@ -1462,7 +1436,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.c else { RenderSoftware(index, m_currentField); -@@ -1156,7 +1200,7 @@ +@@ -1156,7 +1206,7 @@ // imgwidth *= planes[0].pixpertex_x; // imgheight *= planes[0].pixpertex_y; // } @@ -1471,7 +1445,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.c // glBegin(GL_QUADS); // // glMultiTexCoord2fARB(GL_TEXTURE0, planes[0].rect.x1, planes[0].rect.y1); -@@ -1578,6 +1622,75 @@ +@@ -1578,6 +1628,75 @@ #endif } @@ -1547,7 +1521,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.c bool CLinuxRendererGLES::RenderCapture(CRenderCapture* capture) { if (!m_bValidated) -@@ -2299,7 +2412,7 @@ +@@ -2299,7 +2418,7 @@ glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -1556,7 +1530,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.c glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glPixelStorei(GL_UNPACK_ALIGNMENT, 4); -@@ -2405,7 +2518,7 @@ +@@ -2405,7 +2524,7 @@ glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -1565,7 +1539,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.c glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); -@@ -2479,6 +2592,84 @@ +@@ -2479,6 +2598,84 @@ return true; } @@ -1650,7 +1624,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.c void CLinuxRendererGLES::SetTextureFilter(GLenum method) { for (int i = 0 ; iiWidth; ++ plane.texheight = codecinfo->iHeight; ++ ++ CalculateTextureSourceRects(index, 1); + } + -+ YUVFIELDS &fields = m_buffers[index].fields; -+ YUVPLANE &plane = fields[0][0]; -+ plane.texwidth = codecinfo->iWidth; -+ plane.texheight = codecinfo->iHeight; -+ -+ CalculateTextureSourceRects(index, 1); +#endif +} +void CLinuxRendererGLES::DeleteIMXMAPTexture(int index) @@ -1735,7 +1707,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.c bool CLinuxRendererGLES::Supports(ERENDERFEATURE feature) { // Player controls render, let it dictate available render features -@@ -2737,5 +3006,16 @@ +@@ -2737,5 +3010,16 @@ } #endif @@ -1752,9 +1724,9 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.c + #endif -diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.h xbmc-imx6.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.h ---- xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.h 2014-02-19 22:24:45.276494801 +0100 -+++ xbmc-imx6.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.h 2014-02-19 22:25:21.441528772 +0100 +diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.h xbmc-imx6-koying.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.h +--- xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.h 2014-02-21 23:10:30.317096992 +0100 ++++ xbmc-imx6-koying.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.h 2014-02-21 23:11:23.788122322 +0100 @@ -33,6 +33,7 @@ #include "guilib/GraphicContext.h" #include "BaseRenderer.h" @@ -1810,9 +1782,9 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/LinuxRendererGLES.h }; typedef YUVBUFFER YUVBUFFERS[NUM_BUFFERS]; -diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/RenderFormats.h xbmc-imx6.test/xbmc/cores/VideoRenderers/RenderFormats.h ---- xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/RenderFormats.h 2014-02-19 22:24:45.277494802 +0100 -+++ xbmc-imx6.test/xbmc/cores/VideoRenderers/RenderFormats.h 2014-02-19 22:25:21.442528773 +0100 +diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/RenderFormats.h xbmc-imx6-koying.test/xbmc/cores/VideoRenderers/RenderFormats.h +--- xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/RenderFormats.h 2014-02-21 23:10:30.318096992 +0100 ++++ xbmc-imx6-koying.test/xbmc/cores/VideoRenderers/RenderFormats.h 2014-02-21 23:11:23.788122322 +0100 @@ -37,6 +37,8 @@ RENDER_FMT_BYPASS, RENDER_FMT_EGLIMG, @@ -1822,9 +1794,9 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/RenderFormats.h xbm }; #endif -diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/RenderManager.cpp xbmc-imx6.test/xbmc/cores/VideoRenderers/RenderManager.cpp ---- xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/RenderManager.cpp 2014-02-19 22:24:45.276494801 +0100 -+++ xbmc-imx6.test/xbmc/cores/VideoRenderers/RenderManager.cpp 2014-02-19 22:25:21.441528772 +0100 +diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/RenderManager.cpp xbmc-imx6-koying.test/xbmc/cores/VideoRenderers/RenderManager.cpp +--- xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/RenderManager.cpp 2014-02-21 23:10:30.318096992 +0100 ++++ xbmc-imx6-koying.test/xbmc/cores/VideoRenderers/RenderManager.cpp 2014-02-21 23:11:23.788122322 +0100 @@ -928,6 +928,8 @@ else if(pic.format == RENDER_FMT_MEDIACODEC) m_pRenderer->AddProcessor(pic.mediacodec, index); @@ -1834,9 +1806,9 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/RenderManager.cpp x m_pRenderer->ReleaseImage(index, false); -diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp xbmc-imx6.test/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp ---- xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp 2014-02-19 22:24:45.264494789 +0100 -+++ xbmc-imx6.test/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp 2014-02-19 22:25:21.441528772 +0100 +diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp xbmc-imx6-koying.test/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp +--- xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp 2014-02-21 23:10:30.315096991 +0100 ++++ xbmc-imx6-koying.test/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp 2014-02-21 23:11:23.788122322 +0100 @@ -39,12 +39,12 @@ // // Transformation matrixes for different colorspaces. @@ -1893,9 +1865,9 @@ diff -Naur xbmc-gotham-latest.test/xbmc/cores/VideoRenderers/VideoShaders/YUV2RG m_defines += "#define XBMC_YV12\n"; else if (m_format == RENDER_FMT_NV12) m_defines += "#define XBMC_NV12\n"; -diff -Naur xbmc-gotham-latest.test/xbmc/input/linux/LinuxInputDevices.cpp xbmc-imx6.test/xbmc/input/linux/LinuxInputDevices.cpp ---- xbmc-gotham-latest.test/xbmc/input/linux/LinuxInputDevices.cpp 2014-02-19 22:24:41.644491389 +0100 -+++ xbmc-imx6.test/xbmc/input/linux/LinuxInputDevices.cpp 2014-02-19 22:25:21.177528524 +0100 +diff -Naur xbmc-gotham-latest.test/xbmc/input/linux/LinuxInputDevices.cpp xbmc-imx6-koying.test/xbmc/input/linux/LinuxInputDevices.cpp +--- xbmc-gotham-latest.test/xbmc/input/linux/LinuxInputDevices.cpp 2014-02-21 23:10:27.131095441 +0100 ++++ xbmc-imx6-koying.test/xbmc/input/linux/LinuxInputDevices.cpp 2014-02-21 23:11:23.525122201 +0100 @@ -1222,7 +1222,8 @@ if ((now - m_lastHotplugCheck) >= 10) @@ -1906,11 +1878,11 @@ diff -Naur xbmc-gotham-latest.test/xbmc/input/linux/LinuxInputDevices.cpp xbmc-i m_lastHotplugCheck = now; } } -diff -Naur xbmc-gotham-latest.test/xbmc/powermanagement/PowerManager.cpp xbmc-imx6.test/xbmc/powermanagement/PowerManager.cpp -diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/EGLNativeTypeIMX.cpp xbmc-imx6.test/xbmc/windowing/egl/EGLNativeTypeIMX.cpp +diff -Naur xbmc-gotham-latest.test/xbmc/powermanagement/PowerManager.cpp xbmc-imx6-koying.test/xbmc/powermanagement/PowerManager.cpp +diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/EGLNativeTypeIMX.cpp xbmc-imx6-koying.test/xbmc/windowing/egl/EGLNativeTypeIMX.cpp --- xbmc-gotham-latest.test/xbmc/windowing/egl/EGLNativeTypeIMX.cpp 1970-01-01 01:00:00.000000000 +0100 -+++ xbmc-imx6.test/xbmc/windowing/egl/EGLNativeTypeIMX.cpp 2014-02-19 22:25:21.434528766 +0100 -@@ -0,0 +1,225 @@ ++++ xbmc-imx6-koying.test/xbmc/windowing/egl/EGLNativeTypeIMX.cpp 2014-02-21 23:11:23.780122319 +0100 +@@ -0,0 +1,300 @@ +/* + * Copyright (C) 2011-2013 Team XBMC + * http://www.xbmc.org @@ -1940,8 +1912,11 @@ diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/EGLNativeTypeIMX.cpp xbmc- +#include +#include +#include "utils/log.h" ++#include "utils/RegExp.h" +#include "utils/StringUtils.h" ++#include "utils/Environment.h" +#include "guilib/gui3d.h" ++#include "windowing/WindowingFactory.h" + +CEGLNativeTypeIMX::CEGLNativeTypeIMX() +{ @@ -1949,7 +1924,7 @@ diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/EGLNativeTypeIMX.cpp xbmc- + +CEGLNativeTypeIMX::~CEGLNativeTypeIMX() +{ -+} ++} + +bool CEGLNativeTypeIMX::CheckCompatibility() +{ @@ -1963,32 +1938,37 @@ diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/EGLNativeTypeIMX.cpp xbmc- +} + +void CEGLNativeTypeIMX::Initialize() -+{ -+ struct mxcfb_gbl_alpha alpha; ++{ + int fd; + -+ + fd = open("/dev/fb0",O_RDWR); + if (fd < 0) + { + CLog::Log(LOGERROR, "%s - Error while opening /dev/fb0.\n", __FUNCTION__); + return; + } -+ /* Store screen info */ -+ if (ioctl(fd, FBIOGET_VSCREENINFO, &m_screeninfo) != 0) -+ { -+ CLog::Log(LOGERROR, "%s - Error while querying frame buffer.\n", __FUNCTION__); -+ return; -+ } -+ -+ /* Unblank the fbs */ ++ ++ // Unblank the fbs + if (ioctl(fd, FBIOBLANK, 0) < 0) + { + CLog::Log(LOGERROR, "%s - Error while unblanking fb0.\n", __FUNCTION__); + } -+ ++ + close(fd); -+ ++ ++ fd = open("/sys/class/graphics/fb0/mode", O_RDWR); ++ if (fd >= 0) ++ { ++ CLog::Log(LOGNOTICE, "%s - graphics sysfs is writable", __FUNCTION__); ++ m_readonly = false; ++ } ++ else ++ { ++ CLog::Log(LOGNOTICE, "%s - graphics sysfs is read-only", __FUNCTION__); ++ m_readonly = true; ++ } ++ close(fd); ++ + return; +} + @@ -2003,29 +1983,29 @@ diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/EGLNativeTypeIMX.cpp xbmc- + { + CLog::Log(LOGERROR, "%s - Error while opening /dev/fb0.\n", __FUNCTION__); + return; -+ } -+ -+ ioctl( fd, FBIOGET_FSCREENINFO, &fixed_info); -+ /* Black fb0 */ ++ } ++ ++ ioctl( fd, FBIOGET_FSCREENINFO, &fixed_info); ++ // Black fb0 + fb_buffer = mmap(NULL, fixed_info.smem_len, PROT_WRITE, MAP_SHARED, fd, 0); + if (fb_buffer == MAP_FAILED) + { + CLog::Log(LOGERROR, "%s - fb mmap failed %s.\n", __FUNCTION__, strerror(errno)); + } -+ else ++ else + { + memset(fb_buffer, 0x0, fixed_info.smem_len); + munmap(fb_buffer, fixed_info.smem_len); + } -+ -+ close(fd); -+ ++ ++ close(fd); ++ + return; +} + +bool CEGLNativeTypeIMX::CreateNativeDisplay() +{ -+ /* EGL will be rendered on fb0 */ ++ // EGL will be rendered on fb0 + m_display = fbGetDisplayByIndex(0); + m_nativeDisplay = &m_display; + return true; @@ -2033,10 +2013,10 @@ diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/EGLNativeTypeIMX.cpp xbmc- + +bool CEGLNativeTypeIMX::CreateNativeWindow() +{ -+ m_window = fbCreateWindow(m_display, 0, 0, m_screeninfo.xres, m_screeninfo.yres); ++ m_window = fbCreateWindow(m_display, 0, 0, 0, 0); + m_nativeWindow = &m_window; + return true; -+} ++} + +bool CEGLNativeTypeIMX::GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const +{ @@ -2066,56 +2046,68 @@ diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/EGLNativeTypeIMX.cpp xbmc- + +bool CEGLNativeTypeIMX::GetNativeResolution(RESOLUTION_INFO *res) const +{ -+ double drate = 0, hrate = 0, vrate = 0; -+ if (!res) -+ return false; -+ -+ drate = 1e12 / m_screeninfo.pixclock; -+ hrate = drate / (m_screeninfo.left_margin + m_screeninfo.xres + m_screeninfo.right_margin + m_screeninfo.hsync_len); -+ vrate = hrate / (m_screeninfo.upper_margin + m_screeninfo.yres + m_screeninfo.lower_margin + m_screeninfo.vsync_len); -+ -+ res->iWidth = m_screeninfo.xres; -+ res->iHeight = m_screeninfo.yres; -+ res->iScreenWidth = res->iWidth; -+ res->iScreenHeight = res->iHeight; -+ res->fRefreshRate = lrint(vrate); -+ res->dwFlags= D3DPRESENTFLAG_PROGRESSIVE; -+ res->iScreen = 0; -+ res->bFullScreen = true; -+ res->iSubtitles = (int)(0.965 * res->iHeight); -+ res->fPixelRatio = 1.0f; -+ res->strMode = StringUtils::Format("%dx%d @ %.2f%s - Full Screen", res->iScreenWidth, res->iScreenHeight, res->fRefreshRate, -+ res->dwFlags & D3DPRESENTFLAG_INTERLACED ? "i" : ""); -+ -+ return res->iWidth > 0 && res->iHeight> 0; ++ char mode[256] = {0}; ++ get_sysfs_str("/sys/class/graphics/fb0/mode", mode, 255); ++ return ModeToResolution(mode, res); +} + +bool CEGLNativeTypeIMX::SetNativeResolution(const RESOLUTION_INFO &res) +{ -+ return false; ++ if (m_readonly) ++ return false; ++ ++ set_sysfs_str("/sys/class/graphics/fb0/blank", "1"); ++ set_sysfs_str("/sys/class/graphics/fb0/mode", res.strId.c_str()); ++ set_sysfs_str("/sys/class/graphics/fb0/blank", "0"); ++ ++ return true; +} + +bool CEGLNativeTypeIMX::ProbeResolutions(std::vector &resolutions) +{ ++ if (m_readonly) ++ return false; ++ ++ char valstr[256] = {0}; ++ get_sysfs_str("/sys/class/graphics/fb0/modes", valstr, 255); ++ std::vector probe_str; ++ StringUtils::SplitString(valstr, "\n", probe_str); ++ ++ resolutions.clear(); + RESOLUTION_INFO res; -+ bool ret = false; -+ ret = GetNativeResolution(&res); -+ if (ret && res.iWidth > 1 && res.iHeight > 1) ++ for (size_t i = 0; i < probe_str.size(); i++) + { -+ resolutions.push_back(res); -+ return true; ++ if(!StringUtils::StartsWith(probe_str[i], "U:")) // && !StringUtils::StartsWith(mode, "S:")) ++ continue; ++ if(ModeToResolution(probe_str[i].c_str(), &res)) ++ resolutions.push_back(res); + } -+ return false; ++ return resolutions.size() > 0; +} + +bool CEGLNativeTypeIMX::GetPreferredResolution(RESOLUTION_INFO *res) const +{ -+ return false; ++ return GetNativeResolution(res); +} + +bool CEGLNativeTypeIMX::ShowWindow(bool show) +{ -+ // CLog::Log(LOGERROR, "%s - call CEGLNativeTypeIMX::ShowWindow with %d.\n", __FUNCTION__, show); ++ // Force vsync depending on FB_MULTI_BUFFER ++ EGLBoolean status; ++ EGLint result; ++ ++ std::string fb_buffers = CEnvironment::getenv("FB_MULTI_BUFFER"); ++ if (fb_buffers.empty()) ++ status = eglSwapInterval(g_Windowing.GetEGLDisplay(), 0); ++ else ++ { ++ CLog::Log(LOGNOTICE, "%s - FB_MULTI_BUFFER is set",__FUNCTION__); ++ status = eglSwapInterval(g_Windowing.GetEGLDisplay(), 1); ++ } ++ result = eglGetError(); ++ if(result != EGL_SUCCESS) ++ CLog::Log(LOGERROR, "EGL error in %s: %x",__FUNCTION__, result); ++ + return false; +} + @@ -2136,10 +2128,65 @@ diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/EGLNativeTypeIMX.cpp xbmc- + } + return 0; +} -diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/EGLNativeTypeIMX.h xbmc-imx6.test/xbmc/windowing/egl/EGLNativeTypeIMX.h ++ ++int CEGLNativeTypeIMX::set_sysfs_str(const char *path, const char *val) ++{ ++ int fd = open(path, O_RDWR); ++ if (fd >= 0) ++ { ++ write(fd, val, strlen(val)); ++ close(fd); ++ return 0; ++ } ++ return -1; ++} ++ ++bool CEGLNativeTypeIMX::ModeToResolution(const char *mode, RESOLUTION_INFO *res) const ++{ ++ if (!res) ++ return false; ++ ++ res->iWidth = 0; ++ res->iHeight= 0; ++ ++ if(!mode) ++ return false; ++ ++ std::string fromMode = StringUtils::Mid(mode, 2); ++ StringUtils::Trim(fromMode); ++ ++ CRegExp split(true); ++ split.RegComp("([0-9]+)x([0-9]+)([pi])-([0-9]+)"); ++ if (split.RegFind(fromMode) < 0) ++ return false; ++ ++ int w = atoi(split.GetMatch(1).c_str()); ++ int h = atoi(split.GetMatch(2).c_str()); ++ std::string p = split.GetMatch(3); ++ int r = atoi(split.GetMatch(4).c_str()); ++ ++ res->iWidth = w; ++ res->iHeight= h; ++ res->iScreenWidth = w; ++ res->iScreenHeight= h; ++ res->fRefreshRate = r; ++ res->dwFlags = p[0] == 'p' ? D3DPRESENTFLAG_PROGRESSIVE : D3DPRESENTFLAG_INTERLACED; ++ ++ res->iScreen = 0; ++ res->bFullScreen = true; ++ res->iSubtitles = (int)(0.965 * res->iHeight); ++ res->fPixelRatio = 1.0f; ++ res->strMode = StringUtils::Format("%dx%d @ %.2f%s - Full Screen", res->iScreenWidth, res->iScreenHeight, res->fRefreshRate, ++ res->dwFlags & D3DPRESENTFLAG_INTERLACED ? "i" : ""); ++ res->strId = mode; ++ ++ return res->iWidth > 0 && res->iHeight> 0; ++} ++ +diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/EGLNativeTypeIMX.h xbmc-imx6-koying.test/xbmc/windowing/egl/EGLNativeTypeIMX.h --- xbmc-gotham-latest.test/xbmc/windowing/egl/EGLNativeTypeIMX.h 1970-01-01 01:00:00.000000000 +0100 -+++ xbmc-imx6.test/xbmc/windowing/egl/EGLNativeTypeIMX.h 2014-02-19 22:25:21.434528766 +0100 -@@ -0,0 +1,62 @@ ++++ xbmc-imx6-koying.test/xbmc/windowing/egl/EGLNativeTypeIMX.h 2014-02-21 23:11:23.780122319 +0100 +@@ -0,0 +1,60 @@ +#pragma once + +/* @@ -2170,11 +2217,11 @@ diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/EGLNativeTypeIMX.h xbmc-im +public: + CEGLNativeTypeIMX(); + virtual ~CEGLNativeTypeIMX(); -+ virtual std::string GetNativeName() const { return "iMX"; }; ++ virtual std::string GetNativeName() const { return "iMX"; } + virtual bool CheckCompatibility(); + virtual void Initialize(); + virtual void Destroy(); -+ virtual int GetQuirks() { return EGL_QUIRK_NONE; }; ++ virtual int GetQuirks() { return EGL_QUIRK_NONE; } + + virtual bool CreateNativeDisplay(); + virtual bool CreateNativeWindow(); @@ -2191,20 +2238,18 @@ diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/EGLNativeTypeIMX.h xbmc-im + + virtual bool ShowWindow(bool show); + -+ protected: ++protected: ++ bool m_readonly; + int get_sysfs_str(const char *path, char *valstr, const int size) const; ++ int set_sysfs_str(const char *path, const char *val); + bool ModeToResolution(const char *mode, RESOLUTION_INFO *res) const; + + EGLNativeDisplayType m_display; + EGLNativeWindowType m_window; -+ -+protected: -+ struct fb_var_screeninfo m_screeninfo; -+ +}; -diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/EGLWrapper.cpp xbmc-imx6.test/xbmc/windowing/egl/EGLWrapper.cpp ---- xbmc-gotham-latest.test/xbmc/windowing/egl/EGLWrapper.cpp 2014-02-19 22:24:44.600494166 +0100 -+++ xbmc-imx6.test/xbmc/windowing/egl/EGLWrapper.cpp 2014-02-19 22:25:21.434528766 +0100 +diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/EGLWrapper.cpp xbmc-imx6-koying.test/xbmc/windowing/egl/EGLWrapper.cpp +--- xbmc-gotham-latest.test/xbmc/windowing/egl/EGLWrapper.cpp 2014-02-21 23:10:29.976096826 +0100 ++++ xbmc-imx6-koying.test/xbmc/windowing/egl/EGLWrapper.cpp 2014-02-21 23:11:23.780122319 +0100 @@ -17,16 +17,17 @@ * . * @@ -2238,9 +2283,9 @@ diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/EGLWrapper.cpp xbmc-imx6.t { m_nativeTypes = nativeGuess; -diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/Makefile.in xbmc-imx6.test/xbmc/windowing/egl/Makefile.in ---- xbmc-gotham-latest.test/xbmc/windowing/egl/Makefile.in 2014-02-19 22:24:44.557494125 +0100 -+++ xbmc-imx6.test/xbmc/windowing/egl/Makefile.in 2014-02-19 22:25:21.433528765 +0100 +diff -Naur xbmc-gotham-latest.test/xbmc/windowing/egl/Makefile.in xbmc-imx6-koying.test/xbmc/windowing/egl/Makefile.in +--- xbmc-gotham-latest.test/xbmc/windowing/egl/Makefile.in 2014-02-21 23:10:29.933096805 +0100 ++++ xbmc-imx6-koying.test/xbmc/windowing/egl/Makefile.in 2014-02-21 23:11:23.779122318 +0100 @@ -24,6 +24,10 @@ wayland/XBMCSurface.cpp endif