From 3df0f4c55c461c9b9fa185387d0bc1059d6db02d Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sun, 16 Sep 2012 23:01:42 +0200 Subject: [PATCH] Some MVP compile fixes and some RBP clear deinitialisation code --- audioomx.cc | 2 +- boxstack.cc | 2 +- defines.h | 8 +++++ glshader.cc | 2 ++ main.cc | 2 +- osdmvp.cc | 3 +- osdopengl.cc | 22 ++++++++---- osdopengl.h | 6 ++++ remotelinux.cc | 22 +++++++++--- remotelinux.h | 3 ++ surfacemvp.cc | 2 +- videoomx.cc | 91 +++++++++++++++++++++++++++++++++++++++++++------- videoomx.h | 2 ++ vopts.cc | 4 +++ 14 files changed, 142 insertions(+), 29 deletions(-) mode change 100755 => 100644 glshader.cc diff --git a/audioomx.cc b/audioomx.cc index f4a8aec..031adb0 100644 --- a/audioomx.cc +++ b/audioomx.cc @@ -542,7 +542,7 @@ int AudioOMX::ChangeAudioPortConfig(bool disport) //clock aka omx mutex needs to DeAllocateCodecsOMX(); return 0; }*/ - VideoOMX *video=(VideoOMX*)Video::getInstance(); + if (!omx_running) { diff --git a/boxstack.cc b/boxstack.cc index 188a5ed..bee0c81 100644 --- a/boxstack.cc +++ b/boxstack.cc @@ -225,7 +225,7 @@ void BoxStack::deleteBox(int z) void BoxStack::update(Boxx* toUpdate, Region* regionToUpdate) { Log::getInstance()->log("BoxStack", Log::DEBUG, "Update called"); - + if (!initted) return; // it is allowed to call this before init #ifndef WIN32 pthread_mutex_lock(&boxLock); #else diff --git a/defines.h b/defines.h index 7a801fd..fc4f354 100644 --- a/defines.h +++ b/defines.h @@ -111,6 +111,9 @@ long long getTimeMS(); // #define VPE_LIBAV_MPEG2_TRANSCODING #define DEFAULT_TCP_WINDOWSIZENR 6 /*=2048*/ + #define TV_NORM_SWITCHABLE + + #define VOMP_LINUX_CLOCK CLOCK_MONOTONIC #endif #ifdef VOMP_PLATTFORM_MVP @@ -124,6 +127,9 @@ long long getTimeMS(); #define Video_TYPE VideoMVP #define DEFAULT_TCP_WINDOWSIZENR 1 /*=2048*/ #define PAL_WSS + #define MVP_REMOTE_TYPES + + #define VOMP_LINUX_CLOCK CLOCK_REALTIME #endif #ifdef VOMP_PLATTFORM_NMT // This was the attempt to port vomp to nmt, it failed but maybe the code is useful at some time @@ -137,6 +143,8 @@ long long getTimeMS(); #define Video_TYPE VideoNMT #define DEFAULT_TCP_WINDOWSIZENR 1 /*=2048*/ + #define VOMP_LINUX_CLOCK CLOCK_REALTIME + #endif #endif diff --git a/glshader.cc b/glshader.cc old mode 100755 new mode 100644 index e84caa4..fce9c7b --- a/glshader.cc +++ b/glshader.cc @@ -101,5 +101,7 @@ int GLShader::deinitShaders() vertex_shader=0; if (shad_program!=0) glDeleteProgram(shad_program); shad_program=0; + initted=0; + return 0; } diff --git a/main.cc b/main.cc index b60fe02..d837754 100644 --- a/main.cc +++ b/main.cc @@ -567,7 +567,7 @@ void MILLISLEEP(ULONG a) long long getTimeMS() { struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); + clock_gettime(VOMP_LINUX_CLOCK, &ts); return ts.tv_sec*1000+ts.tv_nsec/1000000LL; } diff --git a/osdmvp.cc b/osdmvp.cc index 1f4b22c..0317ea2 100644 --- a/osdmvp.cc +++ b/osdmvp.cc @@ -19,6 +19,7 @@ */ #include "osdmvp.h" +#include "surfacemvp.h" OsdMVP::OsdMVP() { @@ -37,7 +38,7 @@ int OsdMVP::getFD() } Surface * OsdMvp::createNewSurface();{ - return (Surface*)new SurfaceMvp(); + return (Surface*)new SurfaceMVP(); } diff --git a/osdopengl.cc b/osdopengl.cc index cb2e2c0..3abbaf7 100644 --- a/osdopengl.cc +++ b/osdopengl.cc @@ -47,6 +47,7 @@ OsdOpenGL::OsdOpenGL() lastrendertime=getTimeMS(); display_height=0; display_width=0; + mode=0; #ifdef BENCHMARK_FPS last_benchmark_time=getTimeMS(); @@ -152,10 +153,8 @@ int OsdOpenGL::init(void* device) Log::getInstance()->log("OSD", Log::NOTICE, "Displaysize is %d x %d ",display_width, display_height); VC_RECT_T dst_rect ={0,0,display_width,display_height}; VC_RECT_T src_rect={0,0,BACKBUFFER_WIDTH <<16,BACKBUFFER_HEIGHT<<16}; - DISPMANX_DISPLAY_HANDLE_T bcm_display; - DISPMANX_ELEMENT_HANDLE_T bcm_element; - DISPMANX_UPDATE_HANDLE_T bcm_update; + DISPMANX_UPDATE_HANDLE_T bcm_update; bcm_display=vc_dispmanx_display_open(0); bcm_update=vc_dispmanx_update_start(0); @@ -238,10 +237,6 @@ int OsdOpenGL::init(void* device) return 1; } - - - - void OsdOpenGL::InitVertexBuffer(float scalex,float scaley) { @@ -288,8 +283,11 @@ void OsdOpenGL::InitVertexBuffer(float scalex,float scaley) int OsdOpenGL::shutdown() { if (!initted) return 0; + glmutex.Lock(); initted = 0; threadStop(); + delete screen; + screen=NULL; (((VideoOMX*)Video::getInstance())->shutdownUsingOSDObjects()); @@ -303,12 +301,22 @@ int OsdOpenGL::shutdown() eglDestroyContext(egl_display,egl_context); eglTerminate(egl_display ); + DISPMANX_UPDATE_HANDLE_T bcm_update; + bcm_update=vc_dispmanx_update_start(0); + + vc_dispmanx_element_remove(bcm_update,bcm_element); + vc_dispmanx_update_submit_sync(bcm_update); + vc_dispmanx_display_close(bcm_display); + + return 1; } void OsdOpenGL::screenShot(const char* fileName) { + BeginPainting(); screen->screenShot(fileName); + EndPainting(); } void OsdOpenGL::threadMethod() diff --git a/osdopengl.h b/osdopengl.h index 7802d57..d3825c4 100644 --- a/osdopengl.h +++ b/osdopengl.h @@ -99,6 +99,7 @@ class OsdOpenGL : public Osd, public Thread_TYPE + private: //Maybe move the following stuff to a generic opengl object also for boosting DCT etc. @@ -126,6 +127,11 @@ private: uint32_t display_height; uint32_t display_width; + DISPMANX_DISPLAY_HANDLE_T bcm_display; + DISPMANX_ELEMENT_HANDLE_T bcm_element; + + uint32_t mode; + EGLDisplay egl_display; EGLSurface egl_surface; diff --git a/remotelinux.cc b/remotelinux.cc index 8b643ea..0149026 100644 --- a/remotelinux.cc +++ b/remotelinux.cc @@ -115,6 +115,10 @@ int RemoteLinux::init(char* devName) } + return initCec(); +} + +int RemoteLinux::initCec() { // bcm_host_init(); //may be move to custom hardware init? // now init cec @@ -176,16 +180,24 @@ int RemoteLinux::init(char* devName) int RemoteLinux::shutdown() { if (!initted) return 0; - if (cec_adap) { - cec_adap->SetInactiveView(); - cec_adap->Close(); - UnloadLibCec(cec_adap); - } + deinitCec(); + initted = 0; return 1; } +void RemoteLinux::deinitCec() +{ + if (cec_adap) { + cec_adap->SetInactiveView(); + cec_adap->Close(); + UnloadLibCec(cec_adap); + cec_adap = NULL; + } + +} + UCHAR RemoteLinux::getButtonPress(int waitType) { /* how = 0 - block how = 1 - start new wait diff --git a/remotelinux.h b/remotelinux.h index e45cac4..9492951 100644 --- a/remotelinux.h +++ b/remotelinux.h @@ -52,6 +52,9 @@ class RemoteLinux : public Remote const char*HardcodedTranslateStr(UCHAR command); char* HCWDesc(ULLONG hcw); + int initCec(); + void deinitCec(); + private: diff --git a/surfacemvp.cc b/surfacemvp.cc index 5fd5b59..c0fe85b 100644 --- a/surfacemvp.cc +++ b/surfacemvp.cc @@ -361,7 +361,7 @@ int SurfaceMVP::blt(int fd, unsigned long shandle, int sx, int sy, int width, in return ioctl(fd, GFX_FB_OSD_BITBLT, &fblt); } -void SurfaceMVP::screenShot(char* fileName) +void SurfaceMVP::screenShot(const char* fileName) { Log* logger = Log::getInstance(); diff --git a/videoomx.cc b/videoomx.cc index 25444c1..18e43cb 100644 --- a/videoomx.cc +++ b/videoomx.cc @@ -167,6 +167,7 @@ int VideoOMX::shutdown() DeAllocateCodecsOMX(); OMX_Deinit(); + vc_tv_show_info(0); // back to console return 1; } @@ -297,24 +298,90 @@ int VideoOMX::setFormat(UCHAR tformat) { if (!initted) return 0; if ((tformat != PAL) && (tformat != NTSC)) return 0; - format = tformat; + format = PAL; + tvsystem = tformat; -// if (ioctl(fdVideo, AV_SET_VID_DISP_FMT, format) != 0) return 0; - - if (format == NTSC) - { - screenWidth = 720; - screenHeight = 480; - } if (format == PAL) { screenWidth = 720; screenHeight = 576; } +// selectVideoMode(0); + return 1; } +//void VideoOMX::selectVideoMode(int interlaced) +//{ +// if (/*hdmi*/ true) { +// TV_SUPPORTED_MODE_T all_supp_modes[TV_MAX_SUPPORTED_MODES]; +// HDMI_RES_GROUP_T pref_group; +// TV_SUPPORTED_MODE_T *mymode=NULL; +// TV_SUPPORTED_MODE_T *mymode_second_best=NULL; +// bool got_optimum=false; +// uint32_t pref_mode; +// int all_my_modes=vc_tv_hdmi_get_supported_modes(HDMI_RES_GROUP_CEA, +// all_supp_modes,TV_MAX_SUPPORTED_MODES, +// &pref_group,&pref_mode); +// int target_fps=50; +// if (format==PAL)target_fps=50; +// else if (format==NTSC) target_fps=60; +// if (all_my_modes<=0) { +// Log::getInstance()->log("Video", Log::NOTICE, "No CEA modes found abort"); +// return; +// } +// +// //Now first determine native resolution +// int native_width=1920; +// int native_height=1080; +// for (int i=0;ilog("Video", Log::NOTICE, "Found native mode %dx%d %d Hz i: %d", +// mymode->width,mymode->height,mymode->frame_rate,mymode->scan_mode); +// } +// +// } +// //Now find the mode which matches best +// for (int i=0;iwidth==native_width && +// curmode->height==native_height && +// curmode->frame_rate==target_fps) { +// if(curmode->scan_mode==interlaced) { +// got_optimum=true; +// mymode=curmode; +// Log::getInstance()->log("Video", Log::NOTICE, "Found optimum mode %dx%d %d Hz i: %d", +// mymode->width,mymode->height,mymode->frame_rate,mymode->scan_mode); +// } else { +// mymode_second_best=curmode; +// Log::getInstance()->log("Video", Log::NOTICE, "Found close to optimum mode %dx%d %d Hz i: %d", +// mymode_second_best->width,mymode_second_best->height, +// mymode_second_best->frame_rate,mymode_second_best->scan_mode); +// } +// +// } +// } +// if (mymode) { +// Log::getInstance()->log("Video", Log::NOTICE, "Switch to optimum mode"); +// vc_tv_hdmi_power_on_explicit(HDMI_MODE_HDMI,HDMI_RES_GROUP_CEA,mymode->code); +// } else if (mymode_second_best) { +// Log::getInstance()->log("Video", Log::NOTICE, "Switch to close to optimum mode"); +// vc_tv_hdmi_power_on_explicit(HDMI_MODE_HDMI,HDMI_RES_GROUP_CEA,mymode_second_best->code); +// } else { +// Log::getInstance()->log("Video", Log::NOTICE, "Switch to prefered mode"); +// vc_tv_hdmi_power_on_best(1920,1080,target_fps,interlaced?HDMI_INTERLACED:HDMI_NONINTERLACED, +// (EDID_MODE_MATCH_FLAG_T)(HDMI_MODE_MATCH_FRAMERATE|HDMI_MODE_MATCH_RESOLUTION|HDMI_MODE_MATCH_SCANMODE)); +// } +// +// } +// +// +// +//} + + int VideoOMX::setConnection(UCHAR tconnection) { if (!initted) return 0; @@ -2192,15 +2259,15 @@ void VideoOMX::threadMethod() //Log::getInstance()->log("Video", Log::DEBUG, "threadMethod Frameskip"); } else { - Log::getInstance()->log("Video", Log::DEBUG, - "prot empty this buffer in"); + // Log::getInstance()->log("Video", Log::DEBUG, + // "prot empty this buffer in"); OMX_ERRORTYPE error = ProtOMXEmptyThisBuffer(omx_vid_dec, pict); if (error != OMX_ErrorNone) { Log::getInstance()->log("Video", Log::DEBUG, "OMX_EmptyThisBuffer failed %x", error); } - Log::getInstance()->log("Video", Log::DEBUG, - "prot empty this buffer out"); + //Log::getInstance()->log("Video", Log::DEBUG, + // "prot empty this buffer out"); if (deint_first_frame && dodeint) DeinterlaceFix(); if (islast) FrameWaitforDisplay(time); } diff --git a/videoomx.h b/videoomx.h index 59f0d97..be11fdf 100644 --- a/videoomx.h +++ b/videoomx.h @@ -255,6 +255,8 @@ class VideoOMX : public Video, public Thread_TYPE float xpos,ypos; int deinterlace; void updateMode();//called internally to adjust for different parameters + // void selectVideoMode(int interlaced); + UCHAR tvsystem; diff --git a/vopts.cc b/vopts.cc index 64d1bd2..57419ce 100644 --- a/vopts.cc +++ b/vopts.cc @@ -89,9 +89,11 @@ VOpts::VOpts() wop = new WOptionPane(); tabbar.addTab(tr("General"), wop); panes[0] = wop; +#ifdef MVP_REMOTE_TYPES option = new Option(1, "Remote control type", "General", "Remote type", Option::TYPE_TEXT, 2, 0, 0, options1); options.push_back(option); wop->addOptionLine(option); +#endif option = new Option(2, "Language", "General", "LangCode", Option::TYPE_KEYED_TEXT, LangCode.size(), 0, 0, options2, options2keys); options.push_back(option); wop->addOptionLine(option); @@ -264,6 +266,7 @@ void VOpts::doSave() { case 1: { +#ifdef MVP_REMOTE_TYPES if (options[i]->userSetChoice == 1) { Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote"); @@ -274,6 +277,7 @@ void VOpts::doSave() Log::getInstance()->log("Options", Log::DEBUG, "Setting Old Remote"); Remote::getInstance()->setRemoteType(Remote::OLDREMOTE); } +#endif break; } case 2: -- 2.39.5