From a8b07dba8dc814868f61e4838655948cf4dc4f85 Mon Sep 17 00:00:00 2001 From: Tellen Yu Date: Tue, 16 Feb 2016 02:48:40 +0000 Subject: optimize the code Change-Id: Ib7727084492dc8411164cfd2333952dc09c3d8de --- diff --git a/tvapi/libtv/tv/CTv.cpp b/tvapi/libtv/tv/CTv.cpp index 3f4fd4a..3ed762b 100644 --- a/tvapi/libtv/tv/CTv.cpp +++ b/tvapi/libtv/tv/CTv.cpp @@ -72,7 +72,6 @@ static void sqliteLogCallback(void *data, int iErrCode, const char *zMsg) } CTv::CTv() : - mSigDetectThread ( &mTvin ), mSourceConnectDetectThread(&mTvin), mHDMIRxCEC ( &mTvin ), mTvScanner ( &mTvin ), @@ -121,7 +120,7 @@ CTv::CTv() : mpObserver = NULL; fbcIns = NULL; dtv_auto_3d_flag = 0; - m_autoset_displayfreq = false; + mAutoSetDisplayFreq = false; tv_config_load ( TV_CONFIG_FILE_PATH ); sqlite3_config (SQLITE_CONFIG_SERIALIZED); @@ -145,7 +144,7 @@ CTv::CTv() : } m_sig_stable_nums = 0; - m_is_set_hdmi_edid = false; + mSetHdmiEdid = false; m_cur_playing_prog_id = -1; m_hdmi_audio_data = 0; @@ -215,7 +214,6 @@ CTv::CTv() : CTv::~CTv() { - int iRet; mpObserver = NULL; CTvSettingunLoad(); CTvDatabase::deleteTvDb(); @@ -254,18 +252,18 @@ void CTv::onEvent ( const CTvScanner::ScannerEvent &ev ) void CTv::onEvent ( const CFrontEnd::FEEvent &ev ) { const char *config_value = NULL; - LOGD ( "%s, FE event type = %d tvaction=%x", __FUNCTION__, ev.mCurSigStaus, mTvAction); + LOGD ( "%s, FE event type = %d tvaction=%x", __FUNCTION__, ev.mCurSigStaus, mTvAction); if (mTvAction & TV_ACTION_SCANNING) return; //前端事件响应处理 - if ( ev.mCurSigStaus == CFrontEnd::FEEvent::EVENT_FE_HAS_SIG ) { //作为信号稳定 + if ( ev.mCurSigStaus == CFrontEnd::FEEvent::EVENT_FE_HAS_SIG ) { //作为信号稳定 if (/*m_source_input == SOURCE_TV || */m_source_input == SOURCE_DTV && (mTvAction & TV_ACTION_PLAYING)) { //atv and other tvin source not to use it, and if not playing, not use have sig if ( m_win_mode == PREVIEW_WONDOW ) { //mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2); mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_FULL_STRETCH ); } - if ( m_autoset_displayfreq) { + if ( mAutoSetDisplayFreq) { mTvin.VDIN_SetDisplayVFreq ( 50, mAv.getVideoDisplayResolution() , mHdmiOutFbc); } TvEvent::SignalInfoEvent ev; @@ -708,7 +706,6 @@ int CTv::atvMunualScan ( int startFreq, int endFreq, int videoStd, int audioStd, SetAudioMuteForTv ( CC_AUDIO_MUTE ); v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor(vStd, aStd); - tvin_port_t source_port = mTvin.Tvin_GetSourcePortBySourceInput(SOURCE_TV); mTvin.VDIN_OpenPort ( source_port ); @@ -823,7 +820,6 @@ int CTv::playDvbcProgram ( int progId ) CTvProgram prog; int ret = CTvProgram::selectByID ( progId, prog ); - if ( ret != 0 ) { return -1; } @@ -837,18 +833,14 @@ int CTv::playDvbcProgram ( int progId ) int vpid = 0x1fff, apid = 0x1fff, vfmt = -1, afmt = -1; CTvProgram::Video *pV = prog.getVideo(); - CTvProgram::Audio *pA; - if ( pV != NULL ) { vpid = pV->getPID(); vfmt = pV->getFormat(); } int aindex = prog.getCurrentAudio ( String8 ( "eng" ) ); - if ( aindex >= 0 ) { - pA = prog.getAudio ( aindex ); - + CTvProgram::Audio *pA = prog.getAudio ( aindex ); if ( pA != NULL ) { apid = pA->getPID(); afmt = pA->getFormat(); @@ -896,7 +888,6 @@ int CTv::getAudioInfoByIndex ( int progId, int idx, int *pAFmt, String8 &lang ) } iRet = CTvProgram::selectByID ( progId, prog ); - if ( 0 != iRet ) { break; } @@ -906,7 +897,6 @@ int CTv::getAudioInfoByIndex ( int progId, int idx, int *pAFmt, String8 &lang ) } pA = prog.getAudio ( idx ); - if ( NULL == pA ) { break; } @@ -948,7 +938,6 @@ int CTv::switchAudioTrack ( int progId, int idx ) } iOutRet = CTvProgram::selectByID ( progId, prog ); - if ( 0 != iOutRet ) { break; } @@ -1010,7 +999,6 @@ int CTv::playDtvProgram ( int mode, int freq, int para1, int para2, return 0; } - int CTv::playDtmbProgram ( int progId ) { CTvProgram prog; @@ -1032,7 +1020,6 @@ int CTv::playDtmbProgram ( int progId ) mFrontDev.setPara ( channel.getMode(), channel.getFrequency(), channel.getBandwidth(), 0 ); pV = prog.getVideo(); - if ( pV != NULL ) { vpid = pV->getPID(); vfmt = pV->getFormat(); @@ -1199,7 +1186,7 @@ int CTv::stopPlaying() { const char *config_value = NULL; if (!(mTvAction & TV_ACTION_PLAYING)) { - LOGD("%s, stopplay cur action = %x not playing , return", __FUNCTION__, mTvAction); + LOGD("%s, stopplay cur action = %x not playing , return", __FUNCTION__, mTvAction); return 0; } mSigDetectThread.requestAndWaitPauseDetect(); @@ -1241,7 +1228,7 @@ int CTv::getAudioChannel() do { iRet = mAv.AudioGetOutputMode (&audioChanneleMod ); if ( AM_SUCCESS != iRet ) { - LOGD ( "%s, jianfei.lan GetOutputMode is FAILED %d\n", __FUNCTION__, iRet ); + LOGD ( "%s, audio GetOutputMode is FAILED %d\n", __FUNCTION__, iRet ); break; } LOGD ( "%s, jianfei.lan getAudioChannel iRet : %d audioChanneleMod %d\n", __FUNCTION__, iRet, audioChanneleMod ); @@ -1273,23 +1260,17 @@ int CTv::setAudioChannel ( int channelIdx ) int CTv::getFrontendSignalStrength() { - int Strength = 0; - Strength = mFrontDev.getStrength(); - return Strength; + return mFrontDev.getStrength(); } int CTv::getFrontendSNR() { - int snr = 0; - snr = mFrontDev.getSNR(); - return snr; + return mFrontDev.getSNR(); } int CTv::getFrontendBER() { - int ber = 0; - ber = mFrontDev.getBER(); - return ber; + return mFrontDev.getBER(); } int CTv::getChannelInfoBydbID ( int dbID, channel_info_t &chan_info ) @@ -1307,7 +1288,7 @@ int CTv::getChannelInfoBydbID ( int dbID, channel_info_t &chan_info ) SSMReadCVBSStd(&std); chan_info.uInfo.atvChanInfo.videoStd = (atv_video_std_t)std; chan_info.uInfo.atvChanInfo.audioStd = CC_ATV_AUDIO_STD_DK; - chan_info.uInfo.atvChanInfo.isAutoStd = (std == CC_ATV_VIDEO_STD_AUTO) ? 1 : 0; + chan_info.uInfo.atvChanInfo.isAutoStd = (std == CC_ATV_VIDEO_STD_AUTO) ? 1 : 0; return 0; } @@ -1399,21 +1380,18 @@ int CTv::getATVMinMaxFreq ( int *scanMinFreq, int *scanMaxFreq ) *scanMaxFreq = 868250000; config_value = config_get_str ( CFG_SECTION_ATV, "atv.get.min.max.freq", "null" ); - if ( strcmp ( config_value, "null" ) == 0 ) { LOGD ( "%s, atv.get.min.max.freq not set config\n", __FUNCTION__ ); return -1; } - char data_str[512]; - memset ( ( void * ) data_str, 0, sizeof ( data_str ) ); + char data_str[512] = {0}; strncpy ( data_str, config_value, sizeof ( data_str ) - 1 ); char *pSave; token = strtok_r ( data_str, strDelimit, &pSave); sscanf ( token, "%d", scanMinFreq ); token = strtok_r ( NULL, strDelimit , &pSave); - if ( token != NULL ) { sscanf ( token, "%d", scanMaxFreq ); } @@ -1428,10 +1406,9 @@ int CTv::IsDVISignal() int CTv::getHDMIFrameRate() { int ConstRate[5] = {24, 25, 30, 50, 60}; - float ConstRateDiffHz[5] = {0.5, 0.5, 0.5, 2, 2}; //偏差便 + float ConstRateDiffHz[5] = {0.5, 0.5, 0.5, 2, 2}; int fps = mSigDetectThread.getCurSigInfo().fps; - int i = 0; - for (; i < 5; i++) { + for (int i = 0; i < 5; i++) { if (abs(ConstRate[i] - fps) < ConstRateDiffHz[i]) fps = ConstRate[i]; } @@ -1484,7 +1461,6 @@ void CTv::print_version_info ( void ) int CTv::Tvin_GetTvinConfig ( void ) { const char *config_value; - int i = 0; config_value = config_get_str ( CFG_SECTION_TV, "tvin.kernelpet_disable", "null" ); if ( strcmp ( config_value, "disable" ) == 0 ) { @@ -1531,21 +1507,17 @@ TvRunStatus_t CTv::GetTvStatus() int CTv::OpenTv ( void ) { - int tmp_val = 0; const char *value; Tv_Spread_Spectrum(); //reboot system by fbc setting. value = config_get_str ( CFG_SECTION_TV, "fbc.get.panelinfo", "null" ); - LOGD("%s fbc-------------------\n", value); + LOGD("open tv, get fbc panel info:%s\n", value); if ( strcmp ( value, "edid" ) == 0 ) { reboot_sys_by_fbc_edid_info(); } else if ( strcmp ( value, "uart" ) == 0 ) { reboot_sys_by_fbc_uart_panel_info(fbcIns); } - LOGD ( "%s, tv open\n", __FUNCTION__); - char prop_value[PROPERTY_VALUE_MAX] = {0}; - mTvin.Tvin_LoadSourceInputToPortMap(); SSMHandlePreCopying(); @@ -1565,65 +1537,42 @@ int CTv::OpenTv ( void ) //set color filter // SetFileAttrValue ( "/sys/module/amvideo/parameters/filt_mode", "0x2100" ); - value = config_get_str ( CFG_SECTION_TV, "ssm.hdmi_av.hotplug.detect.en", "null" ); - if ( strtoul(value, NULL, 10) == 1 ) { - m_hdmiav_hotplugdetect_en = 1; - } else { - m_hdmiav_hotplugdetect_en = 0; - } - value = config_get_str ( CFG_SECTION_TV, "tvin.autoset.displayfreq", "null" ); - if ( strcmp ( value, "enable" ) == 0 ) { - m_autoset_displayfreq = true; + mAutoSetDisplayFreq = true; } else { - m_autoset_displayfreq = false; - } - - if (mTvin.VDIN_GetDisplayVFreq() == 30) { - m_autoset_displayfreq = false; + mAutoSetDisplayFreq = false; } Tv_HandeHDMIEDIDFilePathConfig(); value = config_get_str ( CFG_SECTION_TV, "ssm.handle.hdmi.edid.en", "null" ); - if ( strtoul(value, NULL, 10) == 1 ) { LOGD( "%s, get config \"%s\" is \"%s\".\n", __FUNCTION__, "ssm.handle.hdmi.edid.en", value ); //get hdmi edid use mode char prop_value[256] = {0}; + char *pEdid = NULL; property_get( "ubootenv.var.outputmode", prop_value, "null" ); LOGD( "%s, get property \"%s\" is \"%s\".\n", __FUNCTION__, "ubootenv.var.outputmode", prop_value ); - if ( strcmp ( prop_value, "null" ) != 0 ) { - config_set_str ( CFG_SECTION_TV, CS_HDMI_EDID_USE_CFG, prop_value ); - char edid_path[256]; - char edid_path_cfg[256]; - //set file's path for hdmi edid of each port - for (int i = 1; i <= SSM_HDMI_PORT_MAX; i++ ) { - memset( edid_path, '\0', 256 ); - memset( edid_path_cfg, '\0', 256 ); - sprintf ( edid_path, "/system/etc/%s_port%d.bin", prop_value, i ); - sprintf ( edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i ); - config_set_str ( CFG_SECTION_TV, edid_path_cfg, edid_path ); - } - } else { - //set default hdmi edid - config_set_str ( CFG_SECTION_TV, CS_HDMI_EDID_USE_CFG, "hdmi_edid" ); - char edid_path[256]; - char edid_path_cfg[256]; - //set file's path for hdmi edid of each port - for ( int i = 1; i <= SSM_HDMI_PORT_MAX; i++ ) { - memset( edid_path, '\0', 256 ); - memset( edid_path_cfg, '\0', 256 ); - sprintf ( edid_path, "/system/etc/%s_port%d.bin", "hdmi_edid", i ); - sprintf ( edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i ); - config_set_str ( CFG_SECTION_TV, edid_path_cfg, edid_path ); - } + + if ( strcmp ( prop_value, "null" ) != 0 ) + pEdid = prop_value; + else + pEdid = "hdmi_edid";//set default hdmi edid + + config_set_str ( CFG_SECTION_TV, CS_HDMI_EDID_USE_CFG, pEdid ); + //set file's path for hdmi edid of each port + for ( int i = 1; i <= SSM_HDMI_PORT_MAX; i++ ) { + char edid_path[256] = {0}; + char edid_path_cfg[256] = {0}; + sprintf ( edid_path, "/system/etc/%s_port%d.bin", pEdid, i ); + sprintf ( edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i ); + config_set_str ( CFG_SECTION_TV, edid_path_cfg, edid_path ); } - m_is_set_hdmi_edid = true; + + mSetHdmiEdid = true; } - // - unsigned char val = 0; + Tvin_GetTvinConfig(); m_last_source_input = SOURCE_INVALID; m_source_input = SOURCE_INVALID; @@ -1634,7 +1583,7 @@ int CTv::OpenTv ( void ) m_blackout_enable = blackout_enable; //dtv init - int rt = -1; + //int rt = -1; //opendemux(); //rt = mFrontDev.Open(FE_ANALOG); //mFrontDev.autoLoadFE(); @@ -1646,7 +1595,6 @@ int CTv::OpenTv ( void ) mAv.Open(); //mTvEpg.Init ( 0, 0, 1, "eng zho chi", "GB2312" ); resetDmxAndAvSource(); - // mSourceConnectDetectThread.startDetect(); mSourceConnectDetectThread.startDetect(); if (SSMReadSerialCMDSwitchValue() == 1) { @@ -1859,7 +1807,6 @@ int CTv::SetSourceSwitchInput (tv_source_input_t source_input ) LOGD ( "%s, source input = %d", __FUNCTION__, source_input ); tv_source_input_t cur_source_input = m_source_input; tvin_port_t cur_port; - const char *config_value = NULL; Tv_SetDDDRCMode(source_input); if (source_input == cur_source_input ) { @@ -1868,7 +1815,7 @@ int CTv::SetSourceSwitchInput (tv_source_input_t source_input ) } //if HDMI, need to set EDID of each port - if (m_is_set_hdmi_edid) { + if (mSetHdmiEdid) { int tmp_ret = 0; switch ( source_input ) { case SOURCE_HDMI1: @@ -1892,7 +1839,7 @@ int CTv::SetSourceSwitchInput (tv_source_input_t source_input ) // SetAudioMuteForTv(CC_AUDIO_MUTE); mSigDetectThread.requestAndWaitPauseDetect(); - config_value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); + //const char *config_value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); //if ( strcmp ( config_value, "black" ) == 0 ) { // mAv.DisableVideoWithBlackColor(); //} else { @@ -2036,7 +1983,7 @@ int CTv::SetSourceSwitchInput (tv_source_input_t source_input ) void CTv::onSigToStable() { - if (m_autoset_displayfreq) { + if (mAutoSetDisplayFreq) { int freq = 60; if (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) { int fps = getHDMIFrameRate(); @@ -2301,7 +2248,7 @@ void CTv::onSigStillNull() void CTv::onStableSigFmtChange() { - if ( m_autoset_displayfreq) { + if ( mAutoSetDisplayFreq) { if (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) { int fps = getHDMIFrameRate(); LOGD("onSigToStable HDMI fps get = %d", fps); @@ -2357,7 +2304,7 @@ void CTv::onSigDetectLoop() if (hdmi_audio_data != m_hdmi_audio_data) { LOGD("HDMI auds_rcv_sts CHANGED = %d", hdmi_audio_data); m_hdmi_audio_data = hdmi_audio_data; - onHMDIAudioStatusChanged(m_hdmi_audio_data); + onHMDIAudioStatusChanged(hdmi_audio_data); } } } @@ -2922,7 +2869,6 @@ int CTv::Tv_SSMFacRestoreDefaultSetting() mVpp.VPPSSMFacRestoreDefault(); AudioSSMRestoreDefaultSetting(); MiscSSMFacRestoreDefault(); - return 0; } /*********************** SSM End **********************/ @@ -2930,7 +2876,7 @@ int CTv::Tv_SSMFacRestoreDefaultSetting() //not in CTv, not use lock void CTv::setSourceSwitchAndPlay() { - int progID = 0, ret = -1; + int progID = 0; CTvProgram prog; LOGD ( "%s\n", __FUNCTION__ ); static const int POWERON_SOURCE_TYPE_NONE = 0;//not play source @@ -2985,9 +2931,7 @@ void CTv::printDebugInfo() //----------------DVR API============================ void CTv::SetRecordFileName ( char *name ) { - char tmp[256]; - strcpy ( tmp, name ); - mTvRec.SetRecordFileName ( tmp ); + mTvRec.SetRecordFileName (name); } void CTv::StartToRecord() @@ -3018,10 +2962,16 @@ int CTv::GetDisplayResolutionInfo() void CTv::onHDMIRxCECMessage(int msg_len, unsigned char msg_buf[]) { - int i = 0; TvEvent::HDMIRxCECEvent ev; + + int bufLen = sizeof(ev.mDataBuf) / sizeof(ev.mDataBuf[0]); + if (msg_len > bufLen) { + LOGE("%s, message len(%d) > buffer len(%d)", __FUNCTION__, msg_len, bufLen); + return; + } + ev.mDataCount = msg_len; - for (i = 0; i < msg_len; i++) { + for (int i = 0; i < msg_len; i++) { ev.mDataBuf[i] = msg_buf[i]; } sendTvEvent(ev); @@ -3029,20 +2979,17 @@ void CTv::onHDMIRxCECMessage(int msg_len, unsigned char msg_buf[]) int CTv::SendHDMIRxCECCustomMessage(unsigned char data_buf[]) { - tv_source_input_t source_input = m_source_input; - return mHDMIRxCEC.SendCustomMessage(source_input, data_buf); + return mHDMIRxCEC.SendCustomMessage(m_source_input, data_buf); } int CTv::SendHDMIRxCECCustomMessageAndWaitReply(unsigned char data_buf[], unsigned char reply_buf[], int WaitCmd, int timeout) { - tv_source_input_t source_input = m_source_input; - return mHDMIRxCEC.SendCustomMessageAndWaitReply(source_input, data_buf, reply_buf, WaitCmd, timeout); + return mHDMIRxCEC.SendCustomMessageAndWaitReply(m_source_input, data_buf, reply_buf, WaitCmd, timeout); } int CTv::SendHDMIRxCECBoradcastStandbyMessage(void) { - tv_source_input_t source_input = m_source_input; - return mHDMIRxCEC.SendBoradcastStandbyMessage(source_input); + return mHDMIRxCEC.SendBoradcastStandbyMessage(m_source_input); } int CTv::SendHDMIRxCECGiveCECVersionMessage(tv_source_input_t source_input, unsigned char data_buf[]) @@ -3110,11 +3057,16 @@ int CTv::StartUpgradeFBC(char *file_name, int mode, int upgrade_blk_size) void CTv::onSerialCommunication(int dev_id, int rd_len, unsigned char data_buf[]) { - int i = 0; TvEvent::SerialCommunicationEvent ev; + + if (rd_len > CC_MAX_SERIAL_RD_BUF_LEN) { + LOGE("%s, rd_len(%d) > buffer len(%d)", __FUNCTION__, rd_len, CC_MAX_SERIAL_RD_BUF_LEN); + return; + } + ev.mDevId = dev_id; ev.mDataCount = rd_len; - for (i = 0; i < rd_len; i++) { + for (int i = 0; i < rd_len; i++) { ev.mDataBuf[i] = data_buf[i]; } sendTvEvent(ev); @@ -3150,7 +3102,7 @@ void CTv::onThermalDetect(int state) if ( strcmp ( value, "enable" ) == 0 ) { value = config_get_str ( CFG_SECTION_TV, "tvin.thermal.threshold.value", "null" ); threshold = atoi(value); - LOGD ( "%s, threshold value: %d\n", __FUNCTION__, threshold); + LOGD ( "%s, threshold value: %d\n", __FUNCTION__, threshold); if (state > threshold) { value_normal = config_get_str ( CFG_SECTION_TV, "tvin.thermal.fbc.normal.value", "null" ); @@ -3158,14 +3110,14 @@ void CTv::onThermalDetect(int state) if (val == 0) { val = 0x4210000; //normal default } - LOGD ( "%s, current temp: %d set 1\n", __FUNCTION__, state); + LOGD ( "%s, current temp: %d set 1\n", __FUNCTION__, state); } else { value_cold = config_get_str ( CFG_SECTION_TV, "tvin.thermal.fbc.cold.value", "null" ); val = atoi(value_cold); if (val == 0) { val = 0x8210000; //cold default } - LOGD ( "%s, current temp: 0x%x set 0\n", __FUNCTION__, state); + LOGD ( "%s, current temp: 0x%x set 0\n", __FUNCTION__, state); } if (pre_val == val) { @@ -3192,10 +3144,8 @@ int CTv::SetDebugSerialOnOff(int on_off) int CTv::GetDebugSerialOnOff() { - char prop[256]; - memset(prop, '\0', 256); + char prop[256] = {0}; property_get("ubootenv.var.console", prop, "null" ); - if (!strcmp(prop, "ttyS0,115200n8")) { return 1; } else { @@ -3258,35 +3208,25 @@ int CTv::SendSerialData(int dev_id, int data_len, unsigned char data_buf[]) int CTv::ChannelExport(const char *destPath) { - //DIR *dirptr = NULL; - //dirptr = opendir("/storage/external_storage/sda1/"); - //if(NULL == dirptr) { - // LOGD("%s, please insert the udisk !",__FUNCTION__); - // return -2; - // } else { char tmp[256]; FILE *fp = NULL; if (destPath == NULL) { destPath = "/storage/external_storage/sda1/"; } - //LOGD("%s, udisk exist !",__FUNCTION__); sprintf(tmp, "cp /param/dtv.db %s", destPath); if (system(tmp) >= 0) { LOGD("%s, copy dtv.db from /param to udisk success !", __FUNCTION__); system("sync"); fp = fopen(destPath, "r"); - if (fp == NULL) { - return -1; - } else { + if (fp != NULL) { fclose(fp); fp = NULL; return 0; } - } else { - return -1; } - //} + + return -1; } int CTv::ChannelImport(const char *srcPath) @@ -3345,61 +3285,40 @@ int CTv::Tv_GetPlatformType() int CTv::Tv_HandeHDMIEDIDFilePathConfig() { - int i, file_exist_flag = 1; - const char *value = NULL; - char val_buf[256]; char edid_path[256]; char edid_path_cfg[256]; + bool fileExist = false; - value = config_get_str(CFG_SECTION_TV, "ssm.handle.hdmi.edid.en", "null"); - + const char *value = config_get_str(CFG_SECTION_TV, "ssm.handle.hdmi.edid.en", "null"); if (strtoul(value, NULL, 10) == 1) { - LOGD( "%s, get config \"%s\" is \"%s\".\n", - __FUNCTION__, "ssm.handle.hdmi.edid.en", value); + LOGD( "%s, get config [ssm.handle.hdmi.edid.en]:[%s]\n", __FUNCTION__, value); //get hdmi edid use mode + char propValue[256] = {0}; + property_get("ubootenv.var.outputmode", propValue, "null"); + LOGD( "%s, get property [ubootenv.var.outputmode]:[%s]\n", __FUNCTION__, propValue); + if (strcmp(propValue, "null") != 0) { + fileExist = true; - memset(val_buf, '\0', 256); - property_get("ubootenv.var.outputmode", val_buf, "null"); - LOGD( "%s, get property \"%s\" is \"%s\".\n", - __FUNCTION__, "ubootenv.var.outputmode", val_buf); - if (strcmp(val_buf, "null") != 0) { - config_set_str ( CFG_SECTION_TV, CS_HDMI_EDID_USE_CFG, val_buf); - - file_exist_flag = 1; + config_set_str ( CFG_SECTION_TV, CS_HDMI_EDID_USE_CFG, propValue); //set file's path for hdmi edid of each port - for (i = 1; i <= SSM_HDMI_PORT_MAX; i++) { + for (int i = 1; i <= SSM_HDMI_PORT_MAX; i++) { memset( edid_path, '\0', 256); memset( edid_path_cfg, '\0', 256); - sprintf(edid_path, "/system/etc/%s_port%d.bin", val_buf, i); + sprintf(edid_path, "/system/etc/%s_port%d.bin", propValue, i); sprintf(edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i); if (access(edid_path, 0) < 0) { - file_exist_flag = 0; + fileExist = false; break; } config_set_str(CFG_SECTION_TV, edid_path_cfg, edid_path); } + } - if (file_exist_flag == 0) { - //set default hdmi edid - config_set_str(CFG_SECTION_TV, CS_HDMI_EDID_USE_CFG, "hdmi_edid"); - //set file's path for hdmi edid of each port - for (i = 1; i <= SSM_HDMI_PORT_MAX; i++) { - memset(edid_path, '\0', 256); - memset(edid_path_cfg, '\0', 256); - sprintf(edid_path, "/system/etc/%s_port%d.bin", "hdmi_edid", i); - sprintf(edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i); - - value = config_get_str(CFG_SECTION_TV, edid_path_cfg, "null"); - if (strcmp(value, edid_path) != 0) { - config_set_str(CFG_SECTION_TV, edid_path_cfg, edid_path); - } - } - } - } else { + if (!fileExist) { //set default hdmi edid config_set_str(CFG_SECTION_TV, CS_HDMI_EDID_USE_CFG, "hdmi_edid"); //set file's path for hdmi edid of each port - for (i = 1; i <= SSM_HDMI_PORT_MAX; i++) { + for (int i = 1; i <= SSM_HDMI_PORT_MAX; i++) { memset(edid_path, '\0', 256); memset(edid_path_cfg, '\0', 256); sprintf(edid_path, "/system/etc/%s_port%d.bin", "hdmi_edid", i); @@ -3411,7 +3330,8 @@ int CTv::Tv_HandeHDMIEDIDFilePathConfig() } } } - m_is_set_hdmi_edid = true; + + mSetHdmiEdid = true; } return 0; } @@ -3605,9 +3525,9 @@ int CTv::SetDisplayMode ( vpp_display_mode_t display_mode, tv_source_input_type_ { LOGD("SetDisplayMode, display_mode = %d, source_type = %d fmt = %d tranfmt = %d\n", display_mode, source_type, sig_fmt, mSigDetectThread.getCurSigInfo().trans_fmt); - tvin_cutwin_t cutwin = mVpp.GetOverscan ( source_type, sig_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt); - LOGD("SetDisplayMode , get crop %d %d %d %d \n", cutwin.vs, cutwin.hs, cutwin.ve, cutwin.he); - int video_screen_mode = CAv::VIDEO_WIDEOPTION_16_9; + tvin_cutwin_t cutwin = mVpp.GetOverscan ( source_type, sig_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt); + LOGD("SetDisplayMode , get crop %d %d %d %d \n", cutwin.vs, cutwin.hs, cutwin.ve, cutwin.he); + int video_screen_mode = CAv::VIDEO_WIDEOPTION_16_9; tvin_window_pos_t win_pos; int display_resolution = Vpp_GetDisplayResolutionInfo(&win_pos); @@ -3668,14 +3588,8 @@ int CTv::SetDisplayMode ( vpp_display_mode_t display_mode, tv_source_input_type_ cutwin.he = cutwin.he + 12; } if (source_type == SOURCE_TYPE_HDMI) { - if ((IsDVISignal()) || (mTvin.GetITContent() == 1)) { - cutwin.vs = 0; - cutwin.hs = 0; - cutwin.ve = 0; - cutwin.he = 0; - } - - if (display_mode == VPP_DISPLAY_MODE_FULL_REAL) { + if ((IsDVISignal()) || (mTvin.GetITContent() == 1) || + (display_mode == VPP_DISPLAY_MODE_FULL_REAL)) { cutwin.vs = 0; cutwin.hs = 0; cutwin.ve = 0; @@ -3722,7 +3636,7 @@ int CTv::Tv_Set2k4k_ScalerUp_Mode ( int value ) CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_TV) { int fd = open("/sys/class/video/frame_height", O_RDONLY); if (fd <= 0) { - LOGE("open /sys/class/video/frame_height ERROR!!error = -%s- \n", strerror ( errno )); + LOGE("open /sys/class/video/frame_height ERROR!!error = -%s- \n", strerror ( errno )); return -1; } read(fd, s, sizeof(s)); @@ -3858,8 +3772,8 @@ vpp_noise_reduction_mode_t CTv::Tv_GetNoiseReductionMode ( tv_source_input_type_ * @parameter mode : 0:sharpness; 1:NR * 1.sharpness分屏(可以控制宽度) - 分屏大小 寄存器范围是0x50000 冿x50780,左效果的范围越来越大?0x70780 冿x70000也是一样? - 左右调换控制 bit 17. 开僿控制 bit 16. 0-11bit 是控制宽度的。范围是0-0x780?920像素? + 分屏大小 寄存器范围是0x50000 冿x50780,左效果的范围越来越大?0x70780 冿x70000也是一? + 左右调换控制 bit 17. 开僿控?bit 16. 0-11bit 是控制宽度的。范围是0-0x780?920像素? 左做效果处理 echo w 0x503c0 v 0x31d6 > /sys/class/amlogic/debug 右做效果处理 echo w 0x703c0 v 0x31d6 > /sys/class/amlogic/debug echo w 0x403c0 v 0x31d6 > /sys/class/amlogic/debug @@ -3867,7 +3781,7 @@ vpp_noise_reduction_mode_t CTv::Tv_GetNoiseReductionMode ( tv_source_input_type_ 2. NR分屏(不能控制宽度) 左做效果处理 echo w 0x07 v 0x174d > /sys /class/amlogic/debug 右做效果处理 echo w 0x70 v 0x174d > /sys /class/amlogic/debug - 僿 echo w 0x77 v 0x174d > /sys/class/amlogic/debug + ? echo w 0x77 v 0x174d > /sys/class/amlogic/debug */ int CTv::Tv_SplitScreenEffect(int mode, int width, int reverse) { @@ -4132,7 +4046,6 @@ int CTv::Tv_FactoryGet_FBC_Brightness ( void ) fbcIns->cfbc_Get_Brightness(COMM_DEV_SERIAL, &temp_value); //data = (temp_value*100)/255; data = temp_value; - return data; } return 0; @@ -4267,12 +4180,9 @@ int CTv::Tv_FactoryGet_FBC_Auto_Backlight_OnOff( void ) int CTv::Tv_FactorySet_FBC_ELEC_MODE( int value ) { - int val = 0; - if (fbcIns != NULL) { fbcIns->cfbc_Set_AUTO_ELEC_MODE(COMM_DEV_SERIAL, value); - val = value; - SSMSaveFBCELECmodeVal(val); + SSMSaveFBCELECmodeVal(value); return 0; } return -1; @@ -4287,10 +4197,7 @@ int CTv::Tv_FactoryGet_FBC_ELEC_MODE( void ) int CTv::Tv_FactorySet_FBC_BACKLIGHT_N360( int value ) { - int val = 0; - - val = value; - SSMSaveFBCELECmodeVal(val); + SSMSaveFBCELECmodeVal(value); return -1; } @@ -5142,28 +5049,22 @@ int CTv::Tv_FactoryGetItemFromBatch(vpp_color_temperature_mode_t colortemp_mode, Tv_FactoryGet_FBC_ColorTemp_Batch((vpp_color_temperature_mode_t)colortemp_mode, ¶ms); switch (item) { case 0: - ret = params.r_gain; - ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(ret); + ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params.r_gain); break; case 1: - ret = params.g_gain; - ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(ret); + ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params.g_gain); break; case 2: - ret = params.b_gain; - ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(ret); + ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params.b_gain); break; case 3: - ret = params.r_post_offset; - ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(ret); + ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params.r_post_offset); break; case 4: - ret = params.g_post_offset; - ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(ret); + ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params.g_post_offset); break; case 5: - ret = params.b_post_offset; - ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(ret); + ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params.b_post_offset); break; default: ret = 0; @@ -5293,11 +5194,9 @@ int CTv::Tv_FactorySet_FBC_LVDS_SSG_Set( int value ) int CTv::Tv_FactorySet_FBC_LightSensor_Status_N310 ( int value ) { - int temp_value = value; - if (fbcIns != NULL) { - fbcIns->cfbc_Set_LightSensor_N310(COMM_DEV_SERIAL, temp_value); - SSMSaveFBCN310LightsensorVal(temp_value); + fbcIns->cfbc_Set_LightSensor_N310(COMM_DEV_SERIAL, value); + SSMSaveFBCN310LightsensorVal(value); return 0; } @@ -5306,12 +5205,9 @@ int CTv::Tv_FactorySet_FBC_LightSensor_Status_N310 ( int value ) int CTv::Tv_FactoryGet_FBC_LightSensor_Status_N310 ( void ) { - int temp_value = 0; int data = 0; - if (fbcIns != NULL) { - SSMReadFBCN310LightsensorVal(&temp_value); - data = temp_value; + SSMReadFBCN310LightsensorVal(&data); return data; } @@ -5320,11 +5216,9 @@ int CTv::Tv_FactoryGet_FBC_LightSensor_Status_N310 ( void ) int CTv::Tv_FactorySet_FBC_Dream_Panel_Status_N310 ( int value ) { - int temp_value = value; - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Dream_Panel_N310(COMM_DEV_SERIAL, temp_value); - SSMSaveFBCN310Dream_PanelVal(temp_value); + fbcIns->cfbc_Set_Dream_Panel_N310(COMM_DEV_SERIAL, value); + SSMSaveFBCN310Dream_PanelVal(value); return 0; } @@ -5333,12 +5227,9 @@ int CTv::Tv_FactorySet_FBC_Dream_Panel_Status_N310 ( int value ) int CTv::Tv_FactoryGet_FBC_Dream_Panel_Status_N310 ( void ) { - int temp_value = 0; int data = 0; - if (fbcIns != NULL) { - SSMReadFBCN310Dream_PanelVal(&temp_value); - data = temp_value; + SSMReadFBCN310Dream_PanelVal(&data); return data; } @@ -5347,11 +5238,9 @@ int CTv::Tv_FactoryGet_FBC_Dream_Panel_Status_N310 ( void ) int CTv::Tv_FactorySet_FBC_MULT_PQ_Status_N310 ( int value ) { - int temp_value = value; - if (fbcIns != NULL) { - fbcIns->cfbc_Set_MULT_PQ_N310(COMM_DEV_SERIAL, temp_value); - SSMSaveFBCN310MULT_PQVal(temp_value); + fbcIns->cfbc_Set_MULT_PQ_N310(COMM_DEV_SERIAL, value); + SSMSaveFBCN310MULT_PQVal(value); return 0; } @@ -5360,12 +5249,10 @@ int CTv::Tv_FactorySet_FBC_MULT_PQ_Status_N310 ( int value ) int CTv::Tv_FactoryGet_FBC_MULT_PQ_Status_N310 ( void ) { - int temp_value = 0; int data = 0; if (fbcIns != NULL) { - SSMReadFBCN310MULT_PQVal(&temp_value); - data = temp_value; + SSMReadFBCN310MULT_PQVal(&data); return data; } @@ -5374,11 +5261,9 @@ int CTv::Tv_FactoryGet_FBC_MULT_PQ_Status_N310 ( void ) int CTv::Tv_FactorySet_FBC_MEMC_Status_N310 ( int value ) { - int temp_value = value; - if (fbcIns != NULL) { - fbcIns->cfbc_Set_MEMC_N310(COMM_DEV_SERIAL, temp_value); - SSMSaveFBCN310MEMCVal(temp_value); + fbcIns->cfbc_Set_MEMC_N310(COMM_DEV_SERIAL, value); + SSMSaveFBCN310MEMCVal(value); return 0; } @@ -5387,12 +5272,9 @@ int CTv::Tv_FactorySet_FBC_MEMC_Status_N310 ( int value ) int CTv::Tv_FactoryGet_FBC_MEMC_Status_N310 ( void ) { - int temp_value = 0; int data = 0; - if (fbcIns != NULL) { - SSMReadFBCN310MEMCVal(&temp_value); - data = temp_value; + SSMReadFBCN310MEMCVal(&data); return data; } @@ -5415,7 +5297,6 @@ int CTv::Tv_FactorySet_FBC_ColorTemp_Mode_N310( int mode ) int CTv::Tv_FactoryGet_FBC_ColorTemp_Mode_N310 ( void ) { int mode = 0; - if (fbcIns != NULL) { SSMReadFBCN310ColorTempVal(&mode); //mode = Tv_FactoryWhiteBalanceColorTempMappingFbc2G9(temp_mode); @@ -5427,12 +5308,9 @@ int CTv::Tv_FactoryGet_FBC_ColorTemp_Mode_N310 ( void ) int CTv::Tv_FactorySet_FBC_Backlight_N310 ( int value ) { - int val = 0; - if (fbcIns != NULL) { fbcIns->cfbc_Set_Backlight(COMM_DEV_SERIAL, value); - val = value; - SSMSaveFBCN310BackLightVal(val); + SSMSaveFBCN310BackLightVal(value); return 0; } @@ -5798,13 +5676,9 @@ int CTv::GetCurAudioSPDIFSwitch() int CTv::SaveCurAudioSPDIFSwitch(int tmp_val) { - int8_t tmp_ch = 0; - mCurAudioSPDIFSwitch = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioSPDIFSwitchVal(tmp_ch); - - return mCurAudioSPDIFSwitch; + SSMSaveAudioSPDIFSwitchVal(tmp_val); + return tmp_val; } int CTv::LoadCurAudioSPDIFSwitch() @@ -5836,13 +5710,9 @@ int CTv::GetCurAudioSPDIFMode() int CTv::SaveCurAudioSPDIFMode(int tmp_val) { - int8_t tmp_ch = 0; - mCurAudioSPDIFMode = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioSPDIFModeVal(tmp_ch); - - return mCurAudioSPDIFMode; + SSMSaveAudioSPDIFModeVal(tmp_val); + return tmp_val; } int CTv::LoadCurAudioSPDIFMode() @@ -5923,7 +5793,7 @@ int CTv::SaveCurAudioMasterVolume(int tmp_vol) { mCurAudioMasterVolume = tmp_vol; SSMSaveAudioMasterVolume(tmp_vol); - return mCurAudioMasterVolume; + return tmp_vol; } int CTv::LoadCurAudioMasterVolume() @@ -5970,13 +5840,9 @@ int CTv::GetCurAudioBalance() int CTv::SaveCurAudioBalance(int tmp_val) { - int8_t tmp_ch = 0; - mCurAudioBalance = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioBalanceVal(tmp_ch); - - return mCurAudioBalance; + SSMSaveAudioBalanceVal(tmp_val); + return tmp_val; } int CTv::LoadCurAudioBalance() @@ -6044,13 +5910,10 @@ int CTv::GetCurAudioSupperBassVolume() int CTv::SaveCurAudioSupperBassVolume(int tmp_vol) { - int8_t tmp_ch = 0; - mCurAudioSupperBassVolume = tmp_vol; - tmp_ch = tmp_vol; - SSMSaveAudioSupperBassVolume(tmp_ch); + SSMSaveAudioSupperBassVolume(tmp_vol); - return mCurAudioSupperBassVolume; + return tmp_vol; } int CTv::LoadCurAudioSupperBassVolume() @@ -6098,15 +5961,10 @@ int CTv::GetCurAudioSupperBassSwitch() int CTv::SaveCurAudioSupperBassSwitch(int tmp_val) { - int8_t tmp_ch = 0; - mCurAudioSupperBassSwitch = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioSupperBassSwitch(tmp_ch); - + SSMSaveAudioSupperBassSwitch(tmp_val); SetSupperBassSRSSpeakerSize(); - - return mCurAudioSupperBassSwitch; + return tmp_val; } int CTv::LoadCurAudioSupperBassSwitch() @@ -6138,7 +5996,6 @@ void CTv::SetSupperBassSRSSpeakerSize() int CTv::SetAudioSRSSurround(int tmp_val) { mCustomAudioSRSSurround = tmp_val; - RefreshSrsEffectAndDacGain(); return 0; } @@ -6155,13 +6012,9 @@ int CTv::GetCurAudioSRSSurround() int CTv::SaveCurAudioSrsSurround(int tmp_val) { - int8_t tmp_ch = 0; - mCurAudioSRSSurround = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioSRSSurroundSwitch(tmp_ch); - - return mCurAudioSRSSurround; + SSMSaveAudioSRSSurroundSwitch(tmp_val); + return tmp_val; } int CTv::LoadCurAudioSrsSurround() @@ -6198,13 +6051,9 @@ int CTv::GetCurAudioSrsDialogClarity() int CTv::SaveCurAudioSrsDialogClarity(int tmp_val) { - int8_t tmp_ch = 0; - mCurAudioSrsDialogClarity = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioSRSDialogClaritySwitch(tmp_ch); - - return mCurAudioSrsDialogClarity; + SSMSaveAudioSRSDialogClaritySwitch(tmp_val); + return tmp_val; } int CTv::LoadCurAudioSrsDialogClarity() @@ -6241,13 +6090,9 @@ int CTv::GetCurAudioSrsTruBass() int CTv::SaveCurAudioSrsTruBass(int tmp_val) { - int8_t tmp_ch = 0; - mCurAudioSrsTruBass = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioSRSTruBassSwitch(tmp_ch); - - return mCurAudioSrsTruBass; + SSMSaveAudioSRSTruBassSwitch(tmp_val); + return tmp_val; } int CTv::LoadCurAudioSrsTruBass() @@ -6401,10 +6246,8 @@ int CTv::SaveCurAudioBassVolume(int tmp_vol) int CTv::RealSaveCurAudioBassVolume(int tmp_vol, int sound_mode_judge) { - int8_t tmp_ch = 0; mCurAudioBassVolume = tmp_vol; - tmp_ch = tmp_vol; - SSMSaveAudioBassVolume(tmp_ch); + SSMSaveAudioBassVolume(tmp_vol); if (sound_mode_judge == 1) { if (GetAudioSoundMode() != CC_SOUND_MODE_USER) { @@ -6482,10 +6325,8 @@ int CTv::SaveCurAudioTrebleVolume(int tmp_vol) int CTv::RealSaveCurAudioTrebleVolume(int tmp_vol, int sound_mode_judge) { - int8_t tmp_ch = 0; mCurAudioTrebleVolume = tmp_vol; - tmp_ch = tmp_vol; - SSMSaveAudioTrebleVolume(tmp_ch); + SSMSaveAudioTrebleVolume(tmp_vol); if (sound_mode_judge == 1) { if (GetAudioSoundMode() != CC_SOUND_MODE_USER) { @@ -6614,13 +6455,9 @@ int CTv::GetCurAudioWallEffect() int CTv::SaveCurAudioWallEffect(int tmp_val) { - int8_t tmp_ch = 0; - mCurAudioWallEffect = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioWallEffectSwitch(tmp_ch); - - return mCurAudioWallEffect; + SSMSaveAudioWallEffectSwitch(tmp_val); + return tmp_val; } int CTv::LoadCurAudioWallEffect() @@ -6655,11 +6492,8 @@ int CTv::GetCurAudioEQMode() int CTv::SaveCurAudioEQMode(int tmp_val) { - int8_t tmp_ch = 0; - mCurAudioEQMode = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioEQModeVal(tmp_ch); + SSMSaveAudioEQModeVal(tmp_val); return tmp_val; } @@ -6734,12 +6568,10 @@ int CTv::RealSaveCurAudioEQGain(int gain_buf[], int sound_mode_judge) int CTv::LoadCurAudioEQGain() { - int i = 0; - SSMReadAudioEQGain(0, GetAudioEQBandCount(), mCurEQGainChBuf); ArrayCopy(mCurEQGainBuf, mCurEQGainChBuf, GetAudioEQBandCount()); - for (i = 0; i < GetAudioEQBandCount(); i++) { + for (int i = 0; i < GetAudioEQBandCount(); i++) { if (mCurEQGainBuf[i] & 0x80) { mCurEQGainBuf[i] = mCurEQGainBuf[i] - 256; } @@ -6937,7 +6769,6 @@ int CTv::SetAtvInGain(int gain_val) int CTv::SetSpecialModeEQGain(int tmp_val) { - int i = 0; int tmpEQPresetBufPtr[24]; if (GetAudioEQPresetBufferPtr(tmpEQPresetBufPtr) != 0) { GetDefault_EQGain_Table(tmpEQPresetBufPtr); @@ -7474,6 +7305,11 @@ int CTv::SendCmdToOffBoardFBCExternalDac(int cmd, int para) int CTv::GetHdmiAvHotplugDetectOnoff() { - return m_hdmiav_hotplugdetect_en; + const char *value = config_get_str ( CFG_SECTION_TV, "ssm.hdmi_av.hotplug.detect.en", "null" ); + if ( strtoul(value, NULL, 10) == 1 ) { + return 1; + } + + return 0; } diff --git a/tvapi/libtv/tv/CTv.h b/tvapi/libtv/tv/CTv.h index d4c65f0..dac799e 100644 --- a/tvapi/libtv/tv/CTv.h +++ b/tvapi/libtv/tv/CTv.h @@ -797,10 +797,9 @@ protected: tv_dtv_scan_running_status_t mDtvScanRunningStatus; volatile tv_config_t gTvinConfig; int dtv_auto_3d_flag; - int m_hdmiav_hotplugdetect_en; - bool m_autoset_displayfreq; + bool mAutoSetDisplayFreq; int m_sig_stable_nums; - bool m_is_set_hdmi_edid; + bool mSetHdmiEdid; /** for L/R or B/T 3d mode overscan **/ /** for 3D **/ VIDEO_3D_MODE_T m_mode_3d; diff --git a/tvapi/libtv/tv/CTvEv.h b/tvapi/libtv/tv/CTvEv.h index 455cffa..7227efb 100644 --- a/tvapi/libtv/tv/CTvEv.h +++ b/tvapi/libtv/tv/CTvEv.h @@ -4,20 +4,21 @@ // @ File Name : // @ Date : 2014-02 // @ Author : -//电视通知消息的基类 -#if !defined(_CTVEV_H) -#define _CTVEV_H +#ifndef _CTVEV_H_ +#define _CTVEV_H_ + #include #define CC_MAX_SERIAL_RD_BUF_LEN (1200) + using namespace android; class CTvEv { public: static const int TV_EVENT_COMMOM = 0;//通用消息 static const int TV_EVENT_SCANNER = 1;//搜索消息 - static const int TV_EVENT_EPG = 2;//EPG状态消息 + static const int TV_EVENT_EPG = 2;//EPG static const int TV_EVENT_SOURCE_SWITCH = 3;//信源切换 - static const int TV_EVENT_SIGLE_DETECT = 4;//信号检测 + static const int TV_EVENT_SIGLE_DETECT = 4; static const int TV_EVENT_ADC_CALIBRATION = 5;//ADC校准 static const int TV_EVENT_VGA = 6;//VGA static const int TV_EVENT_3D_STATE = 7;//3D @@ -36,8 +37,7 @@ public: CTvEv(int type); virtual ~CTvEv() {}; - int getEvType() const - { + int getEvType() const { return mEvType; }; private: @@ -48,12 +48,8 @@ namespace TvEvent { //events class SignalInfoEvent: public CTvEv { public: - SignalInfoEvent() : CTvEv ( CTvEv::TV_EVENT_SIGLE_DETECT ) - { - } - ~SignalInfoEvent() - { - } + SignalInfoEvent() : CTvEv ( CTvEv::TV_EVENT_SIGLE_DETECT ) {} + ~SignalInfoEvent() {} int mTrans_fmt; int mFmt; int mStatus; @@ -62,35 +58,23 @@ namespace TvEvent { class VGAEvent: public CTvEv { public: - VGAEvent() : CTvEv ( CTvEv::TV_EVENT_VGA ) - { - } - ~VGAEvent() - { - } + VGAEvent() : CTvEv ( CTvEv::TV_EVENT_VGA ) {} + ~VGAEvent() {} int mState; }; class ADCCalibrationEvent: public CTvEv { public: - ADCCalibrationEvent() : CTvEv ( CTvEv::TV_EVENT_ADC_CALIBRATION ) - { - } - ~ADCCalibrationEvent() - { - } + ADCCalibrationEvent() : CTvEv ( CTvEv::TV_EVENT_ADC_CALIBRATION ) {} + ~ADCCalibrationEvent() {} int mState; }; class SerialCommunicationEvent: public CTvEv { public: - SerialCommunicationEvent(): CTvEv(CTvEv::TV_EVENT_SERIAL_COMMUNICATION) - { - } - ~SerialCommunicationEvent() - { - } - public: + SerialCommunicationEvent(): CTvEv(CTvEv::TV_EVENT_SERIAL_COMMUNICATION) {} + ~SerialCommunicationEvent() {} + int mDevId; int mDataCount; unsigned char mDataBuf[CC_MAX_SERIAL_RD_BUF_LEN]; @@ -98,54 +82,38 @@ namespace TvEvent { class SourceConnectEvent: public CTvEv { public: - SourceConnectEvent() : CTvEv ( CTvEv::TV_EVENT_SOURCE_CONNECT ) - { - } - ~SourceConnectEvent() - { - } + SourceConnectEvent() : CTvEv ( CTvEv::TV_EVENT_SOURCE_CONNECT ) {} + ~SourceConnectEvent() {} int mSourceInput; int connectionState; }; class HDMIRxCECEvent: public CTvEv { public: - HDMIRxCECEvent() : CTvEv ( CTvEv::TV_EVENT_HDMIRX_CEC ) - { - } - ~HDMIRxCECEvent() - { - } + HDMIRxCECEvent() : CTvEv ( CTvEv::TV_EVENT_HDMIRX_CEC ) {} + ~HDMIRxCECEvent() {} int mDataCount; int mDataBuf[32]; }; class AVPlaybackEvent: public CTvEv { public: - AVPlaybackEvent() : CTvEv ( CTvEv::TV_EVENT_AV_PLAYBACK ) - { - } - ~AVPlaybackEvent() - { - } - static const int EVENT_AV_PLAYBACK_NODATA = 1; - static const int EVENT_AV_PLAYBACK_RESUME = 2; - static const int EVENT_AV_SCAMBLED = 3; - static const int EVENT_AV_UNSUPPORT = 4; + AVPlaybackEvent() : CTvEv ( CTvEv::TV_EVENT_AV_PLAYBACK ) {} + ~AVPlaybackEvent() {} + static const int EVENT_AV_PLAYBACK_NODATA = 1; + static const int EVENT_AV_PLAYBACK_RESUME = 2; + static const int EVENT_AV_SCAMBLED = 3; + static const int EVENT_AV_UNSUPPORT = 4; - public: int mMsgType; int mProgramId; }; + class BlockEvent: public CTvEv { public: - BlockEvent() : CTvEv ( CTvEv::TV_EVENT_BLOCK ) - { - } - ~BlockEvent() - { - } - public: + BlockEvent() : CTvEv ( CTvEv::TV_EVENT_BLOCK ) {} + ~BlockEvent() {} + bool block_status; int programBlockType; String8 vchipDimension; @@ -155,38 +123,28 @@ namespace TvEvent { class UpgradeFBCEvent: public CTvEv { public: - UpgradeFBCEvent() : CTvEv ( CTvEv::TV_EVENT_UPGRADE_FBC ) - { - } - ~UpgradeFBCEvent() - { - } + UpgradeFBCEvent() : CTvEv ( CTvEv::TV_EVENT_UPGRADE_FBC ) {} + ~UpgradeFBCEvent() {} int mState; int param; }; class HeadSetOf2d4GEvent: public CTvEv { public: - HeadSetOf2d4GEvent(): CTvEv(CTvEv::TV_EVENT_2d4G_HEADSET) - { - } - ~HeadSetOf2d4GEvent() - { - } - public: + HeadSetOf2d4GEvent(): CTvEv(CTvEv::TV_EVENT_2d4G_HEADSET) {} + ~HeadSetOf2d4GEvent() {} + int state; int para; }; + class SubtitleEvent: public CTvEv { public: - SubtitleEvent(): CTvEv(CTvEv::TV_EVENT_SUBTITLE) - { - } - ~SubtitleEvent() - { - } + SubtitleEvent(): CTvEv(CTvEv::TV_EVENT_SUBTITLE) {} + ~SubtitleEvent() {} int pic_width; int pic_height; }; }; #endif + diff --git a/tvapi/libtv/tvin/CTvin.cpp b/tvapi/libtv/tvin/CTvin.cpp index 8b07c69..07e5b67 100644 --- a/tvapi/libtv/tvin/CTvin.cpp +++ b/tvapi/libtv/tvin/CTvin.cpp @@ -67,6 +67,7 @@ typedef enum { VIEWMODE_16_9 } view_mode_t; int CTvin::mSourceInputToPortMap[SOURCE_MAX]; + CTvin::CTvin() { int i = 0; @@ -100,7 +101,6 @@ CTvin::CTvin() CTvin::~CTvin() { - } int CTvin::OpenTvin() @@ -267,7 +267,6 @@ int CTvin::VDIN_RmTvPath ( void ) int CTvin::VDIN_AddVideoPath ( int selPath ) { int ret = -1; - char prop_value[PROPERTY_VALUE_MAX]; switch ( selPath ) { case TV_PATH_VDIN_AMVIDEO: @@ -338,6 +337,7 @@ int CTvin::VDIN_RmPreviewPath ( void ) return ret; } + int CTvin::VDIN_OpenModule() { char file_name[64]; @@ -503,16 +503,13 @@ int CTvin::VDIN_OnoffVScaler ( int isOn ) isOn = 0; } - fp = fopen ( "/sys/class/video/vscaler", "w" ); - if ( fp == NULL ) { LOGW ( "Open /sys/class/video/vscaler error(%s)!\n", strerror ( errno ) ); return -1; } fprintf ( fp, "%d", ( int ) isOn ); - fclose ( fp ); fp = NULL; @@ -824,20 +821,16 @@ int CTvin::VDIN_Get3DDetc ( void ) int ret = -1; char buf[10]; - fd = open ( "/sys/module/di/parameters/det3d_en", O_RDWR ); - if ( fd < 0 ) { LOGW ( "Open /sys/module/di/parameters/det3d_en error(%s)!\n", strerror ( errno ) ); return -1; } ret = read ( fd, buf, sizeof ( buf ) ); - close ( fd ); fd = -1; - if ( strcmp ( "enable", buf ) == 0 ) { return 1; } else { @@ -852,23 +845,19 @@ int CTvin::VDIN_GetVscalerStatus ( void ) int ret = -1; char buf[7]; - fd = open ( "/sys/class/video/vscaler", O_RDWR ); - if ( fd < 0 ) { LOGW ( "Open /sys/class/video/vscaler error(%s)!\n", strerror ( errno ) ); return -1; } ret = read ( fd, buf, sizeof ( buf ) ); - close ( fd ); fd = -1; sscanf ( buf, "%d", &ret ); ret = ( ( ret & 0x40000 ) == 0 ) ? 1 : 0; - if ( ret == 1 ) { sleep ( 1 ); } @@ -880,16 +869,13 @@ int CTvin::VDIN_TurnOnBlackBarDetect ( int isEnable ) { FILE *fp = NULL; - fp = fopen ( "/sys/module/tvin_vdin/parameters/black_bar_enable", "w" ); - if ( fp == NULL ) { LOGW ( "Open /sys/module/tvin_vdin/parameters/black_bar_enable error(%s)!\n", strerror ( errno ) ); return -1; } fprintf ( fp, "%d", isEnable ); - fclose ( fp ); fp = NULL; @@ -914,16 +900,13 @@ int CTvin::VDIN_LoadHdcpKey ( unsigned char *hdcpkey_buff ) int ret = -1; int fd = -1; - fd = open ( "/sys/class/hdmirx/hdmirx0/edid", O_RDWR ); - if ( fd < 0 ) { LOGW ( "Open hdmi hdcp key error(%s)!!\n", strerror ( errno ) ); return -1; } ret = write ( fd, testHdcp, 368 ); - if ( ret < 0 ) { LOGD ( "Write hdmi hdcp key error(%s)!!\n", strerror ( errno ) ); } @@ -936,11 +919,9 @@ int CTvin::VDIN_LoadHdcpKey ( unsigned char *hdcpkey_buff ) int CTvin::VDIN_KeepLastFrame ( int enable ) { - FILE *fp = NULL; - return 0; - - + /* + FILE *fp = NULL; fp = fopen ( "/sys/module/amvideo/parameters/keep_old_frame", "w" ); if ( fp == NULL ) { @@ -954,15 +935,14 @@ int CTvin::VDIN_KeepLastFrame ( int enable ) fp = NULL; return 0; + */ } int CTvin::VDIN_SetVideoFreeze ( int enable ) { FILE *fp = NULL; - fp = fopen ( "/sys/class/vdin/vdin0/attr", "w" ); - if ( fp == NULL ) { LOGW ( "Open /sys/class/vdin/vdin0/attr error(%s)!\n", strerror ( errno ) ); return -1; @@ -984,16 +964,13 @@ int CTvin::VDIN_SetDIBypasshd ( int enable ) { FILE *fp = NULL; - fp = fopen ( "/sys/module/di/parameters/bypass_hd", "w" ); - if ( fp == NULL ) { LOGW ( "Open /sys/module/di/parameters/bypass_hd error(%s)!\n", strerror ( errno ) ); return -1; } fprintf ( fp, "%d", enable ); - fclose ( fp ); fp = NULL; @@ -1005,7 +982,6 @@ int CTvin::VDIN_SetDIBypassAll ( int enable ) FILE *fp = NULL; fp = fopen ( "/sys/module/di/parameters/bypass_all", "w" ); - if ( fp == NULL ) { LOGW ( "Open /sys/module/di/parameters/bypass_all error(%s)!\n", strerror ( errno ) ); return -1; @@ -1021,16 +997,13 @@ int CTvin::VDIN_SetDIBypass_Get_Buf_Threshold ( int enable ) { FILE *fp = NULL; - fp = fopen ( "/sys/module/di/parameters/bypass_get_buf_threshold", "w" ); - if ( fp == NULL ) { LOGW ( "Open /sys/module/di/parameters/bypass_get_buf_threshold error(%s)!\n", strerror ( errno ) ); return -1; } fprintf ( fp, "%d", enable ); - fclose ( fp ); fp = NULL; @@ -1042,16 +1015,13 @@ int CTvin::VDIN_SetDIBypassProg ( int enable ) { FILE *fp = NULL; - fp = fopen ( "/sys/module/di/parameters/bypass_prog", "w" ); - if ( fp == NULL ) { LOGW ( "Open /sys/module/di/parameters/bypass_prog error(%s)!\n", strerror ( errno ) ); return -1; } fprintf ( fp, "%d", enable ); - fclose ( fp ); fp = NULL; @@ -1062,16 +1032,13 @@ int CTvin::VDIN_SetDIBypassDynamic ( int flag ) { FILE *fp = NULL; - fp = fopen ( "/sys/module/di/parameters/bypass_dynamic", "w" ); - if ( fp == NULL ) { LOGW ( "Open /sys/module/di/parameters/bypass_dynamic error(%s)!\n", strerror ( errno ) ); return -1; } fprintf ( fp, "%d", flag ); - fclose ( fp ); fp = NULL; @@ -1082,16 +1049,13 @@ int CTvin::VDIN_SetDIDet3DMode ( int value ) { FILE *fp = NULL; - fp = fopen ( "/sys/module/di/parameters/det3d_mode", "w" ); - if ( fp == NULL ) { LOGW ( "Open /sys/module/di/parameters/det3d_mode error(%s)!\n", strerror ( errno ) ); return -1; } fprintf ( fp, "%d", value ); - fclose ( fp ); fp = NULL; @@ -1102,7 +1066,6 @@ int CTvin::VDIN_SetDIBypass3D ( int enable ) { FILE *fp = NULL; - fp = fopen ( "/sys/module/di/parameters/bypass_3d", "w" ); if ( fp == NULL ) { @@ -1111,7 +1074,6 @@ int CTvin::VDIN_SetDIBypass3D ( int enable ) } fprintf ( fp, "%d", enable ); - fclose ( fp ); fp = NULL; @@ -1122,16 +1084,13 @@ int CTvin::VDIN_SetDIBypassPost ( int enable ) { FILE *fp = NULL; - fp = fopen ( "/sys/module/di/parameters/bypass_post", "w" ); - if ( fp == NULL ) { LOGW ( "Open /sys/module/di/parameters/bypass_post error(%s)!\n", strerror ( errno ) ); return -1; } fprintf ( fp, "%d", enable ); - fclose ( fp ); fp = NULL; @@ -1178,37 +1137,31 @@ int CTvin::VDIN_SetDIProg_Proc_Config ( int value ) { FILE *fp = NULL; - fp = fopen ( "/sys/module/di/parameters/prog_proc_config", "w" ); - if ( fp == NULL ) { LOGW ( "Open /sys/module/di/parameters/prog_proc_config error(%s)!\n", strerror ( errno ) ); return -1; } - fprintf ( fp, "%d", value ); - fclose ( fp ); fp = NULL; return 0; } + #if(1) int CTvin::VDIN_SetDIInput2Pre ( int value ) { FILE *fp = NULL; - fp = fopen ( "/sys/module/di/parameters/input2pre", "w" ); - if ( fp == NULL ) { LOGW ( "Open /sys/module/di/parameters/input2pre error(%s)!\n", strerror ( errno ) ); return -1; } fprintf ( fp, "%d", value ); - fclose ( fp ); fp = NULL; @@ -1222,7 +1175,6 @@ int CTvin::VDIN_SetVdinFlag ( int flag ) int freq = 1200000; fp = fopen ( "/sys/class/vdin/memp", "w" ); - if ( fp == NULL ) { LOGW ( "Open /sys/class/vdin/memp error(%s)!\n", strerror ( errno ) ); return -1; @@ -1254,7 +1206,6 @@ int CTvin::VDIN_EnableRDMA ( int enable ) // AFE int CTvin::AFE_OpenModule ( void ) { - if ( afe_dev_fd < 0 ) { afe_dev_fd = open ( AFE_DEV_PATH, O_RDWR ); @@ -1283,7 +1234,6 @@ int CTvin::AFE_DeviceIOCtl ( int request, ... ) va_list ap; void *arg; - if ( afe_dev_fd >= 0 ) { va_start ( ap, request ); arg = va_arg ( ap, void * ); @@ -2008,7 +1958,6 @@ struct adc_cal_s CTvin::get_n_frame_average ( enum adc_cal_type_e calType ) } } - memset ( &mem_data, 0, sizeof ( mem_data ) ); for ( i = 0; i < ( 1 << ( ADC_CAL_FRAME_QTY_ORDER - 1 ) ); i++ ) { //(1<<(ADC_CAL_FRAME_QTY_ORDER-1)) @@ -2149,10 +2098,8 @@ int CTvin::TvinApi_SetCompPhase ( am_phase_t &am_phase ) LOGD ( "enter,TvinApi_SetCompPhase" ); fd = open ( "/sys/module/tvin_afe/parameters/comp_phase", O_RDWR ); - if ( fd < 0 ) { LOGW ( "Open vdin_comp_phase_op_mutex error(%s)!!\n", strerror ( errno ) ); - return -1; } @@ -2166,7 +2113,6 @@ int CTvin::TvinApi_SetCompPhase ( am_phase_t &am_phase ) LOGD ( "##########str1 = %s\n", str1 ); ret = write ( fd, str1, strlen ( str1 ) ); - if ( ret < 0 ) { LOGD ( "Write vdin_comp_phase_op_mutex error(%s)!!\n", strerror ( errno ) ); } @@ -2180,7 +2126,6 @@ int CTvin::TvinApi_SetCompPhase ( am_phase_t &am_phase ) tvin_trans_fmt CTvin::TvinApi_Get3DDectMode() { - int fd; int ret; char det_3d[10]; @@ -2188,7 +2133,6 @@ tvin_trans_fmt CTvin::TvinApi_Get3DDectMode() //LOGW("det_3dmode %d\n", det_3dmode); fd = open ( "/sys/module/di/parameters/det3d_mode", O_RDWR ); - if ( fd < 0 ) { LOGW ( "/sys/module/di/parameters/det3d_mode error(%s)!!\n", strerror ( errno ) ); @@ -2196,7 +2140,6 @@ tvin_trans_fmt CTvin::TvinApi_Get3DDectMode() } ret = read ( fd, det_3d, 10 ); - if ( ret < 0 ) { LOGW ( "/sys/module/di/parameters/det3d_mode error(%s)!!\n", strerror ( errno ) ); } @@ -2207,10 +2150,10 @@ tvin_trans_fmt CTvin::TvinApi_Get3DDectMode() return (tvin_trans_fmt)det_3dmode; } + int CTvin::TvinApi_SetCompPhaseEnable ( int enable ) { int ret = -1; - if ( enable == 1 ) { ret = SetFileAttrValue ( "/sys/module/tvin_afe/parameters/enable_dphase", "Y" ); LOGD ( "%s, enable TvinApi_SetCompPhase.", CFG_SECTION_TV ); @@ -2234,17 +2177,14 @@ int CTvin::VDIN_GetPortConnect ( int port ) } //LOGD("%s, port:%x,status:%d", CFG_SECTION_TV,port,status); - return status; } int CTvin::VDIN_OpenHDMIPinMuxOn ( bool flag ) { FILE *fp = NULL; - int status = 1; fp = fopen ( "/sys/class/hdmirx/hdmirx0/debug", "w" ); - if ( fp == NULL ) { LOGW ( "Open /sys/class/hdmirx/hdmirx0/debug(%s)!\n", strerror ( errno ) ); return -1; @@ -2259,7 +2199,7 @@ int CTvin::VDIN_OpenHDMIPinMuxOn ( bool flag ) fclose ( fp ); fp = NULL; - return status; + return 1; } int CTvin::VDIN_GetHdmiHdcpKeyKsvInfo(struct _hdcp_ksv *msg) @@ -2311,7 +2251,6 @@ int CTvin::TVAFE_EnablePlugInDetect ( bool flag ) int status = 1; fp = fopen ( "/sys/class/tvafe/tvafe0/debug", "w" ); - if ( fp == NULL ) { LOGW ( "Open /sys/class/tvafe/tvafe0/debug (%s)!\n", strerror ( errno ) ); return -1; @@ -2333,7 +2272,7 @@ int CTvin::TvinApi_GetHDMIAudioStatus ( void ) { int fd; int val = 0; - char bcmd[16]; + char bcmd[16]; fd = open ( "/sys/module/tvin_hdmirx/parameters/auds_rcv_sts", O_RDONLY ); if ( fd >= 0 ) { @@ -2370,7 +2309,6 @@ int CTvin::TvinApi_LoadCVD2Values ( am_regs_t regs ) return rt; } - int CTvin::TvinApi_GetFbSize ( unsigned int *fb_width, unsigned int *fb_height ) { int fbfd = 0; @@ -2379,7 +2317,6 @@ int CTvin::TvinApi_GetFbSize ( unsigned int *fb_width, unsigned int *fb_height ) int xres = 0, yres = 0, bits_per_pixel = 0; fbfd = open ( "/dev/graphics/fb0", O_RDWR ); - if ( !fbfd ) { return -1; } @@ -2394,7 +2331,6 @@ int CTvin::TvinApi_GetFbSize ( unsigned int *fb_width, unsigned int *fb_height ) *fb_width = vinfo.xres; *fb_height = vinfo.yres; - return 1; fail_close_fb: @@ -2466,7 +2402,6 @@ tvin_port_t CTvin::Tvin_GetSourcePortBySourceType ( tv_source_input_type_t sourc return source_port; } - tvin_port_t CTvin::Tvin_GetSourcePortBySourceInput ( tv_source_input_t source_input ) { tvin_port_t source_port = TVIN_PORT_NULL; @@ -2560,8 +2495,6 @@ void CTvin::Tvin_LoadSourceInputToPortMap() mSourceInputToPortMap[SOURCE_MPEG] = TVIN_PORT_MPEG0; mSourceInputToPortMap[SOURCE_DTV] = TVIN_PORT_DTV; mSourceInputToPortMap[SOURCE_IPTV] = TVIN_PORT_BT656; - - return; } int CTvin::Tvin_GetSourcePortByCECPhysicalAddress(int physical_addr) @@ -2620,7 +2553,6 @@ tv_audio_in_source_type_t CTvin::Tvin_GetAudioInSourceType ( tv_source_input_t s if (strcasecmp(config_value, "TV_AUDIO_IN_SOURCE_TYPE_ATV") == 0) { return TV_AUDIO_IN_SOURCE_TYPE_ATV; } - return TV_AUDIO_IN_SOURCE_TYPE_LINEIN; } else if (source_input == SOURCE_AV1 || source_input == SOURCE_AV2) { return TV_AUDIO_IN_SOURCE_TYPE_LINEIN; } else if (source_input == SOURCE_YPBPR1 || source_input == SOURCE_YPBPR2 || source_input == SOURCE_VGA) { @@ -2727,7 +2659,6 @@ bool CTvin::Tvin_is50HzFrameRateFmt ( tvin_sig_fmt_t fmt ) } } - bool CTvin::Tvin_IsDeinterlaceFmt ( tvin_sig_fmt_t fmt ) { if ( fmt == TVIN_SIG_FMT_COMP_480I_59HZ_D940 @@ -3009,7 +2940,6 @@ int CTvin::Tvin_CheckPathActive ( tv_path_type_t path_type, int isCheckD2D3 ) memset ( path, 0, 255 ); f = fopen ( "/sys/class/vfm/map", "r" ); - if ( !f ) { LOGE ( "%s, can not open /sys/class/vfm/map!\n", CFG_SECTION_TV ); return TV_PATH_STATUS_NO_DEV; @@ -3087,9 +3017,8 @@ int CTvin::get_hdmi_sampling_rate() { int fd; int val = 0; - char bcmd[16]; + char bcmd[16]; fd = open ( "/sys/module/tvin_hdmirx/parameters/audio_sample_rate", O_RDONLY ); - if ( fd >= 0 ) { read ( fd, bcmd, sizeof ( bcmd ) ); val = strtol ( bcmd, NULL, 10 ); @@ -3099,27 +3028,17 @@ int CTvin::get_hdmi_sampling_rate() return val; } - //************************************************************************** -CTvin::CTvinSigDetect::CTvinSigDetect ( CTvin *pTvin ) +CTvin::CTvinSigDetect::CTvinSigDetect () { - m_cur_sig_info.trans_fmt = TVIN_TFMT_2D; - m_cur_sig_info.fmt = TVIN_SIG_FMT_NULL; - m_cur_sig_info.status = TVIN_SIG_STATUS_NULL; - m_cur_sig_info.reserved = 0; - - m_pre_sig_info = m_cur_sig_info; mDetectState = STATE_STOPED; mpObserver = NULL; - mpTvin = pTvin; - mKeepNosigTime = 0; - mResumeLaterTime = 0; - m_is_nosig_checktimes_once_valid = false; + + initSigState(); } CTvin::CTvinSigDetect::~CTvinSigDetect() { - } int CTvin::CTvinSigDetect::startDetect(bool bPause) @@ -3137,7 +3056,6 @@ int CTvin::CTvinSigDetect::startDetect(bool bPause) m_pre_sig_info = m_cur_sig_info; - // m_request_pause_detect = bPause; this->run(); return mDetectState; @@ -3197,14 +3115,15 @@ int CTvin::CTvinSigDetect::resumeDetect(int later)//ms void CTvin::CTvinSigDetect::setVdinNoSigCheckKeepTimes(int times, bool isOnce) { - LOGD("setVdinNoSigCheckKeepTimes mKeepNosigTime = %d, times = %d", mKeepNosigTime, times); + LOGD("setVdinNoSigCheckKeepTimes mKeepNosigTime = %d, times = %d", mKeepNosigTime, times); mKeepNosigTime = times; m_is_nosig_checktimes_once_valid = isOnce; } int CTvin::CTvinSigDetect::Tv_TvinSigDetect ( int &sleeptime ) { - mpTvin->VDIN_GetSignalInfo ( &m_cur_sig_info ); //get info + CTvin tvin; + tvin.VDIN_GetSignalInfo ( &m_cur_sig_info ); //get info //set no sig check times static long long sNosigKeepTime = 0; //LOGD("stime=%d status=%d, fmt = %d sNosigKeepTime = %d, mKeepNosigTime = %d", sleeptime, m_cur_sig_info.status,m_cur_sig_info.fmt, sNosigKeepTime, mKeepNosigTime); @@ -3216,67 +3135,44 @@ int CTvin::CTvinSigDetect::Tv_TvinSigDetect ( int &sleeptime ) m_is_nosig_checktimes_once_valid = false; mKeepNosigTime = 0; } - // } else {//not m_cur_sig_info.status = m_pre_sig_info.status; } } else { sNosigKeepTime = 0; - // if ( m_is_nosig_checktimes_once_valid ) { //just once change,not nosig,default is m_is_nosig_checktimes_once_valid = false; mKeepNosigTime = 0; } - // } //if state change if ( m_cur_sig_info.status != m_pre_sig_info.status ) { - //sleeptime = 200; + sleeptime = 20; if ( m_cur_sig_info.status == TVIN_SIG_STATUS_STABLE ) { // to stable - // - sleeptime = 20; mpObserver->onSigToStable(); } else if ( m_pre_sig_info.status == TVIN_SIG_STATUS_STABLE && m_cur_sig_info.status == TVIN_SIG_STATUS_UNSTABLE ) { //stable to unstable - // //mVpp.Tvin_SetVideoScreenColorType ( TV_SIGNAL_BLACK_PATTERN ); - sleeptime = 20; mpObserver->onSigStableToUnstable(); } else if ( m_pre_sig_info.status == TVIN_SIG_STATUS_STABLE && m_cur_sig_info.status == TVIN_SIG_STATUS_NOTSUP ) { - // - sleeptime = 20; mpObserver->onSigStableToUnSupport(); } else if ( m_pre_sig_info.status == TVIN_SIG_STATUS_STABLE && m_cur_sig_info.status == TVIN_SIG_STATUS_NOSIG ) { - // - sleeptime = 20; mpObserver->onSigStableToNoSig(); } else if ( m_pre_sig_info.status == TVIN_SIG_STATUS_UNSTABLE && m_cur_sig_info.status == TVIN_SIG_STATUS_NOTSUP ) { - // - sleeptime = 20; mpObserver->onSigUnStableToUnSupport(); } else if ( m_pre_sig_info.status == TVIN_SIG_STATUS_UNSTABLE && m_cur_sig_info.status == TVIN_SIG_STATUS_NOSIG ) { - // - sleeptime = 20; mpObserver->onSigUnStableToNoSig(); } else if ( m_pre_sig_info.status == TVIN_SIG_STATUS_NULL && m_cur_sig_info.status == TVIN_SIG_STATUS_NOSIG ) { - // - sleeptime = 20; mpObserver->onSigNullToNoSig(); } else if ( m_pre_sig_info.status == TVIN_SIG_STATUS_NOSIG && m_cur_sig_info.status == TVIN_SIG_STATUS_UNSTABLE ) { - // - sleeptime = 20; mpObserver->onSigNoSigToUnstable(); - } else { - sleeptime = 20; } } else { //state not change - //sleeptime = 500; + sleeptime = 20; switch ( m_cur_sig_info.status ) { case TVIN_SIG_STATUS_STABLE: - // - sleeptime = 20;//sleeptime = 500; mpObserver->onSigStillStable(); if ( m_cur_sig_info.trans_fmt != m_pre_sig_info.trans_fmt ) { mpObserver->onStableTransFmtChange(); @@ -3287,43 +3183,29 @@ int CTvin::CTvinSigDetect::Tv_TvinSigDetect ( int &sleeptime ) break; case TVIN_SIG_STATUS_NOTSUP: - // - sleeptime = 20; mpObserver->onSigStillNoSupport(); break; case TVIN_SIG_STATUS_UNSTABLE: - // - sleeptime = 20; mpObserver->onSigStillUnstable(); break; case TVIN_SIG_STATUS_NOSIG: - // - sleeptime = 20; mpObserver->onSigStillNosig(); break; case TVIN_SIG_STATUS_NULL: - // - sleeptime = 20; - mpObserver->onSigStillNull(); - break; - default: - // - sleeptime = 20; mpObserver->onSigStillNull(); break; } } m_pre_sig_info = m_cur_sig_info;//backup info - return sleeptime; } -bool CTvin::CTvinSigDetect::threadLoop() +bool CTvin::CTvinSigDetect::threadLoop() { //enter onStart() if ( mpObserver == NULL ) { @@ -3350,9 +3232,7 @@ bool CTvin::CTvinSigDetect::threadLoop() } } - // mResumeLaterTime = 0; - // mpObserver->onSigDetectLoop(); Tv_TvinSigDetect ( sleeptime ); //可以优化 @@ -3383,7 +3263,6 @@ v4l2_std_id CTvin::CvbsFtmToV4l2ColorStd(tvin_sig_fmt_t fmt) return v4l2_std; } - int CTvin::CvbsFtmToColorStdEnum(tvin_sig_fmt_t fmt) { v4l2_std_id v4l2_std; diff --git a/tvapi/libtv/tvin/CTvin.h b/tvapi/libtv/tvin/CTvin.h index c680f94..1f7b8be 100644 --- a/tvapi/libtv/tvin/CTvin.h +++ b/tvapi/libtv/tvin/CTvin.h @@ -1156,7 +1156,7 @@ public: class CTvinSigDetect: public CThread { public: static const int VDIN_NOSIG_DEFAULT_CHECK_TIMES = 1; - CTvinSigDetect ( CTvin *pTvin ); + CTvinSigDetect (); ~CTvinSigDetect(); int startDetect(bool bPause = true); int stopDetect(); @@ -1210,7 +1210,6 @@ public: tvin_info_t m_pre_sig_info; int mKeepNosigTime; bool m_is_nosig_checktimes_once_valid; - CTvin *mpTvin; mutable CMutex mLock; CCondition mDetectPauseCondition; CCondition mRequestPauseCondition; diff --git a/tvapi/libtv/tvutils/CSerialCommunication.h b/tvapi/libtv/tvutils/CSerialCommunication.h index bd963d3..d4e7e5a 100644 --- a/tvapi/libtv/tvutils/CSerialCommunication.h +++ b/tvapi/libtv/tvutils/CSerialCommunication.h @@ -3,8 +3,7 @@ #include "CThread.h" #include "CSerialPort.h" - -#define CC_MAX_SERIAL_RD_BUF_LEN (1200) +#include "../tv/CTvEv.h" class CSerialCommunication: public CThread { public: diff --git a/tvapi/libtv/vpp/CVpp.cpp b/tvapi/libtv/vpp/CVpp.cpp index 0a00049..70c79b8 100644 --- a/tvapi/libtv/vpp/CVpp.cpp +++ b/tvapi/libtv/vpp/CVpp.cpp @@ -177,8 +177,7 @@ int CVpp::Vpp_LoadRegs(am_regs_t regs) int CVpp::isPreviewWindow() { - char prop_value[PROPERTY_VALUE_MAX]; - memset(prop_value, '\0', PROPERTY_VALUE_MAX); + char prop_value[PROPERTY_VALUE_MAX] = {0}; property_get("tv.is.preview.window", prop_value, "false"); LOGD("%s, prop tv.is.preview.window is \"%s\".\n", __FUNCTION__, prop_value); return (strcmp(prop_value, "true") == 0) ? 1 : 0; @@ -248,13 +247,8 @@ int CVpp::LoadVppSettings(tv_source_input_type_t source_type, tvin_sig_fmt_t sig int CVpp::Vpp_GetVppConfig(void) { const char *config_value; - int cfg_item_count = 0; - char *token = NULL; - const char *strDelimit = ","; - char data_str[CC_CFG_VALUE_STR_MAX_LEN] = { 0 }; config_value = config_get_str(CFG_SECTION_TV, "vpp.pqmode.depend.bklight", "null"); - if (strcmp(config_value, "enable") == 0) { mbVppCfg_pqmode_depend_bklight = true; } else { @@ -262,7 +256,6 @@ int CVpp::Vpp_GetVppConfig(void) } config_value = config_get_str(CFG_SECTION_TV, "vpp.color.temp.bysource", "enable"); - if (strcmp(config_value, "enable") == 0) { mbVppCfg_colortemp_by_source = true; } else { @@ -270,7 +263,6 @@ int CVpp::Vpp_GetVppConfig(void) } config_value = config_get_str(CFG_SECTION_TV, "vpp.panoroma.switch", "null"); - if (strcmp(config_value, "enable") == 0) { mbVppCfg_panorama_switch = true; } else { @@ -278,7 +270,6 @@ int CVpp::Vpp_GetVppConfig(void) } config_value = config_get_str(CFG_SECTION_TV, "vpp.backlight.reverse", "null"); - if (strcmp(config_value, "enable") == 0) { mbVppCfg_backlight_reverse = true; } else { @@ -286,7 +277,6 @@ int CVpp::Vpp_GetVppConfig(void) } config_value = config_get_str(CFG_SECTION_TV, "vpp.backlight.init", "null"); - if (strcmp(config_value, "enable") == 0) { mbVppCfg_backlight_init = true; } else { @@ -294,7 +284,6 @@ int CVpp::Vpp_GetVppConfig(void) } config_value = config_get_str(CFG_SECTION_TV, "vpp.pqwithout.hue", "null"); - if (strcmp(config_value, "enable") == 0) { mbVppCfg_pqmode_without_hue = true; } else { @@ -302,7 +291,6 @@ int CVpp::Vpp_GetVppConfig(void) } config_value = config_get_str(CFG_SECTION_TV, "vpp.hue.reverse", "null"); - if (strcmp(config_value, "enable") == 0) { mbVppCfg_hue_reverse = true; } else { @@ -310,7 +298,6 @@ int CVpp::Vpp_GetVppConfig(void) } config_value = config_get_str(CFG_SECTION_TV, "vpp.gamma.onoff", "null"); - if (strcmp(config_value, "disable") == 0) { mbVppCfg_gamma_onoff = true; } else { @@ -318,7 +305,6 @@ int CVpp::Vpp_GetVppConfig(void) } config_value = config_get_str(CFG_SECTION_TV, "vpp.whitebalance.same_param", "null"); - if (strcmp(config_value, "enable") == 0) { mbVppCfg_whitebalance_sameparam = true; } else { @@ -326,7 +312,6 @@ int CVpp::Vpp_GetVppConfig(void) } config_value = config_get_str(CFG_SECTION_TV, "vpp.new.cm", "disable"); - if (strcmp(config_value, "enable") == 0) { mbVppCfg_new_cm = true; } else { @@ -334,7 +319,6 @@ int CVpp::Vpp_GetVppConfig(void) } config_value = config_get_str(CFG_SECTION_TV, "vpp.new.nr", "disable"); - if (strcmp(config_value, "enable") == 0) { mbVppCfg_new_nr = true; } else { @@ -366,7 +350,7 @@ int CVpp::Vpp_LoadBasicRegs(tv_source_input_type_t source_type, tvin_sig_fmt_t s is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) { am_regs_t regs; - int ret = -1, rangeRet = -1, formatRet = -1, enableFlag = -1; + int ret = -1, enableFlag = -1; tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); @@ -1353,26 +1337,26 @@ int CVpp::Vpp_LoadGamma(tv_source_input_type_t source_type, tvin_sig_fmt_t sig_f /*int CVpp::SetGammaValue(int gammaValue) { - int ret = -1; - tvin_sig_fmt_t sig_fmt = TVIN_SIG_FMT_NULL; - tv_source_input_type_t source_type = SOURCE_TYPE_TV; - sig_fmt = Tvin_GetSigFormat(); - source_type = Tvin_GetSrcInputType(); - LOGD("%s, source_type = %d, sig_fmt = %d, gammaValue = %d\n", __FUNCTION__, (int)source_type, - (int)sig_fmt, gammaValue); - if (gammaValue >= -4 || gammaValue <= 4) { - switch (gammaValue) { - case 0: - ret = Vpp_LoadGammaDefault(source_type, sig_fmt); - break; - default: - ret = Vpp_LoadGammaSpecial(gammaValue); - break; - } - if (0 == ret) - ret = SSMSaveGammaValue(gammaValue); - } - return ret; + int ret = -1; + tvin_sig_fmt_t sig_fmt = TVIN_SIG_FMT_NULL; + tv_source_input_type_t source_type = SOURCE_TYPE_TV; + sig_fmt = Tvin_GetSigFormat(); + source_type = Tvin_GetSrcInputType(); + LOGD("%s, source_type = %d, sig_fmt = %d, gammaValue = %d\n", __FUNCTION__, (int)source_type, + (int)sig_fmt, gammaValue); + if (gammaValue >= -4 || gammaValue <= 4) { + switch (gammaValue) { + case 0: + ret = Vpp_LoadGammaDefault(source_type, sig_fmt); + break; + default: + ret = Vpp_LoadGammaSpecial(gammaValue); + break; + } + if (0 == ret) + ret = SSMSaveGammaValue(gammaValue); + } + return ret; }*/ int CVpp::GetGammaValue() -- cgit