From 440094c1ab3e13e9aa07711ce39f447b861320b5 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Wed, 7 Nov 2012 08:46:15 +0100 Subject: [PATCH] Changes in analog tv mode switching --- videoomx.cc | 102 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 41 deletions(-) diff --git a/videoomx.cc b/videoomx.cc index 8512ffd..db69e66 100644 --- a/videoomx.cc +++ b/videoomx.cc @@ -347,54 +347,47 @@ int VideoOMX::setFormat(UCHAR tformat) void VideoOMX::selectVideoMode(int interlaced) { + TV_GET_STATE_RESP_T tvstate; + vc_tv_get_state(&tvstate); - 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; - HDMI_RES_GROUP_T group=HDMI_RES_GROUP_CEA; - 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); - if (all_my_modes<=0) { - group=HDMI_RES_GROUP_DMT; - all_my_modes=vc_tv_hdmi_get_supported_modes(HDMI_RES_GROUP_DMT, + if ((tvstate.state & VC_HDMI_UNPLUGGED)) { + hdmi = false; + Log::getInstance()->log("Video", Log::NOTICE, "HDMI unplugged"); + } else { + hdmi = true; + Log::getInstance()->log("Video", Log::NOTICE, "HDMI plugged"); + if (connection==COMPOSITERGB) { + hdmi=false; + Log::getInstance()->log("Video", Log::NOTICE, "SDTV set"); + } else { + hdmi=true; + Log::getInstance()->log("Video", Log::NOTICE, "HDMI set"); + } + } + + + if (hdmi) { + 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; + HDMI_RES_GROUP_T group=HDMI_RES_GROUP_CEA; + 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); + if (all_my_modes<=0) { + group=HDMI_RES_GROUP_DMT; + all_my_modes=vc_tv_hdmi_get_supported_modes(HDMI_RES_GROUP_DMT, all_supp_modes,TV_MAX_SUPPORTED_MODES, &pref_group,&pref_mode); - Log::getInstance()->log("Video", Log::NOTICE, "No CEA fall back to DMT modes "); - } + Log::getInstance()->log("Video", Log::NOTICE, "No CEA fall back to DMT modes "); + } - if (all_my_modes<=0 || connection==COMPOSITERGB ) { - /* analog tv case */ - Log::getInstance()->log("Video", Log::NOTICE, "No CEA and DMT modes found analog tv case?"); - Remote::getInstance()->shutdown(); - vc_tv_power_off(); - SDTV_MODE_T setmode=SDTV_MODE_PAL; - SDTV_OPTIONS_T options; - switch (tvsize) { - default: - case ASPECT16X9: - Log::getInstance()->log("Video", Log::NOTICE, "SDTV aspect 16:9"); - options.aspect=SDTV_ASPECT_16_9; break; - case ASPECT4X3: - Log::getInstance()->log("Video", Log::NOTICE, "SDTV aspect 4:3"); - options.aspect=SDTV_ASPECT_4_3; break; - case ASPECT14X9: - Log::getInstance()->log("Video", Log::NOTICE, "SDTV aspect 14:9"); - options.aspect=SDTV_ASPECT_14_9; break; - }; - if (format==PAL) setmode=SDTV_MODE_PAL; - else if (format==NTSC) setmode=SDTV_MODE_NTSC; - else if (format==PAL_M)setmode=SDTV_MODE_PAL_M; - else if (format==NTSC_J) setmode=SDTV_MODE_NTSC_J; - vc_tv_sdtv_power_on(setmode,&options); - hdmi=false; - } else { int target_fps=50; if (format==PAL)target_fps=50; else if (format==NTSC) target_fps=60; @@ -447,6 +440,33 @@ void VideoOMX::selectVideoMode(int interlaced) } hdmi=true; outputinterlaced=interlaced; + } else { + /* analog tv case */ + Log::getInstance()->log("Video", Log::NOTICE, "No CEA and DMT modes found analog tv case?"); + Remote::getInstance()->shutdown(); + vc_tv_power_off(); + SDTV_MODE_T setmode=SDTV_MODE_PAL; + SDTV_OPTIONS_T options; + + switch (tvsize) { + default: + case ASPECT16X9: + Log::getInstance()->log("Video", Log::NOTICE, "SDTV aspect 16:9"); + options.aspect=SDTV_ASPECT_16_9; break; + case ASPECT4X3: + Log::getInstance()->log("Video", Log::NOTICE, "SDTV aspect 4:3"); + options.aspect=SDTV_ASPECT_4_3; break; + case ASPECT14X9: + Log::getInstance()->log("Video", Log::NOTICE, "SDTV aspect 14:9"); + options.aspect=SDTV_ASPECT_14_9; break; + }; + + if (format==PAL) setmode=SDTV_MODE_PAL; + else if (format==NTSC) setmode=SDTV_MODE_NTSC; + else if (format==PAL_M)setmode=SDTV_MODE_PAL_M; + else if (format==NTSC_J) setmode=SDTV_MODE_NTSC_J; + vc_tv_sdtv_power_on(setmode,&options); + hdmi=false; } Remote::getInstance()->init(""); -- 2.39.5