summaryrefslogtreecommitdiff
path: root/tvapi/libtv/tv/CTv.cpp (plain)
blob: 0131fc7a730c6429dd77c77bbc2ea98ac4d2aa61
1//
2//
3// amlogic 2013
4//
5// @ Project : tv
6// @ File Name : CTv.cpp
7// @ Date : 2013-11
8// @ Author :
9#include <stdio.h>
10#include <unistd.h>
11#include <fcntl.h>
12#include <dirent.h>
13#include <am_epg.h>
14#include <am_mem.h>
15#include "CTvDatabase.h"
16#include <stdlib.h>
17#include <string.h>
18#include <malloc.h>
19#include <pthread.h>
20#include <sys/types.h>
21#include <errno.h>
22#include <dlfcn.h>
23#include <cutils/properties.h>
24#include <cutils/log.h>
25#include <cutils/android_reboot.h>
26#include <utils/threads.h>
27#include <time.h>
28#include <sys/prctl.h>
29#include <getopt.h>
30#include <errno.h>
31#include <sys/types.h>
32#include <sys/stat.h>
33#include <fcntl.h>
34#include <stdlib.h>
35#ifdef ANDROID
36#include <termios.h>
37#endif
38#include <string.h>
39#include <signal.h>
40
41#include "../version/version.h"
42#include "../tvsetting/CTvSetting.h"
43#include "../tvutils/tvutils.h"
44#include "../tvconfig/tvconfig.h"
45#include "../tvutils/CFile.h"
46#include <hardware_legacy/power.h>
47#include "../tvutils/serial_operate.h"
48
49extern "C" {
50#include "am_ver.h"
51#include "am_misc.h"
52#include "am_debug.h"
53#include "am_fend.h"
54}
55
56#include <math.h>
57#include <sys/ioctl.h>
58
59#include "CTv.h"
60
61#define LOG_TAG "CTv"
62
63
64using namespace android;
65
66// Called each time a message is logged.
67static void sqliteLogCallback(void *data, int iErrCode, const char *zMsg)
68{
69 LOGD( "showbo sqlite (%d) %s\n", iErrCode, zMsg);
70}
71
72
73
74CTv::CTv() : mSigDetectThread ( &mTvin ), mSourceConnectDetectThread(&mTvin), mHDMIRxCEC ( &mTvin ), mTvScanner ( &mTvin ), mTvMsgQueue(this), mAutoBackLight( &mVpp, &mTvin )
75{
76 //mpClient = pClient;
77 //copy file to param
78 if ( Tv_Utils_IsFileExist ( TV_CONFIG_FILE_SYSTEM_PATH ) == 0 ) {
79 if ( Tv_Utils_IsFileExist ( TV_CONFIG_FILE_PARAM_PATH ) != 0 ) {
80 CFile file ( TV_CONFIG_FILE_SYSTEM_PATH );
81
82 if ( file.copyTo ( TV_CONFIG_FILE_PARAM_PATH ) != 0 ) {
83 LOGE ( "%s, copy file = %s , error", __FUNCTION__, TV_CONFIG_FILE_PARAM_PATH );
84 }
85 }
86 }
87
88 if ( Tv_Utils_IsFileExist ( TV_CHANNEL_LIST_SYSTEM_PATH ) == 0 ) {
89 if ( Tv_Utils_IsFileExist ( TV_CHANNEL_LIST_PARAM_PATH ) != 0 ) {
90 CFile file ( TV_CHANNEL_LIST_SYSTEM_PATH );
91
92 if ( file.copyTo ( TV_CHANNEL_LIST_PARAM_PATH ) != 0 ) {
93 LOGE ( "%s, copy file = %s , error", __FUNCTION__, TV_CHANNEL_LIST_PARAM_PATH );
94 }
95 }
96 }
97
98 //ssm
99 if ( Tv_Utils_IsFileExist ( TV_SSM_DATA_SYSTEM_PATH ) == 0 ) {
100 if ( Tv_Utils_IsFileExist ( TV_SSM_DATA_PARAM_PATH ) != 0 ) {
101 CFile file ( TV_SSM_DATA_SYSTEM_PATH );
102
103 if ( file.copyTo ( TV_SSM_DATA_PARAM_PATH ) != 0 ) {
104 LOGE ( "%s, copy file = %s , error", __FUNCTION__, TV_SSM_DATA_PARAM_PATH );
105 }
106 }
107 }
108
109 AM_EVT_Init();
110 mTvEpg.setObserver ( &mTvMsgQueue );
111 mpObserver = NULL;
112 audio_sr = 0;
113 mIsFbc = false;
114 dtv_auto_3d_flag = 0;
115 m_autoset_displayfreq = false;
116 m_cur_set_info_fmt = TVIN_SIG_FMT_CVBS_PAL_I;
117
118 tv_config_load ( TV_CONFIG_FILE_PATH );
119 sqlite3_config (SQLITE_CONFIG_SERIALIZED);
120 //sqlite3_config(SQLITE_CONFIG_LOG, &sqliteLogCallback, (void*)1);
121 sqlite3_soft_heap_limit(8 * 1024 * 1024);
122 // Initialize SQLite.
123 sqlite3_initialize();
124 CTvDatabase::GetTvDb()->InitTvDb ( TV_DB_PATH );
125
126 if ( CTvDimension::isDimensionTblExist() == false ) {
127 CTvDimension::builtinAtscDimensions();
128 }
129
130 CTvSettingLoad();
131
132 mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL;
133
134 m_sig_stable_nums = 0;
135 m_is_set_hdmi_edid = false;
136 m_cur_playing_prog_id = -1;
137
138 mSigDetectThread.setObserver ( this );
139 mSourceConnectDetectThread.setObserver ( this );
140 mHDMIRxCEC.setObserver(this);
141 mFrontDev.setObserver ( &mTvMsgQueue );
142 mpUpgradeFBC = NULL;
143 if (GetPlatformHaveFBCFlag() == 1) {
144 mIsFbc = true;
145
146 mpUpgradeFBC = new CUpgradeFBC();
147 mpUpgradeFBC->setObserver(this);
148 }
149 mSerialA.setObserver(this);
150 mSerialB.setObserver(this);
151 mSerialC.setObserver(this);
152 mAv.setObserver(&mTvMsgQueue);
153 mTvScanner.setGlobalScanerObject(&mTvScanner);
154 mTvAction = mTvAction & TV_ACTION_NULL;
155 mTvStatus = TV_INIT_ED;
156 print_version_info();
157};
158
159CTv::~CTv()
160{
161 int iRet;
162 mpObserver = NULL;
163 CTvSettingunLoad();
164 CTvDatabase::deleteTvDb();
165 tv_config_unload();
166 mAv.Close();
167 mTvStatus = TV_INIT_ED;
168 mFrontDev.Close();
169
170 if (mpUpgradeFBC != NULL) {
171 delete mpUpgradeFBC;
172 mpUpgradeFBC = NULL;
173 }
174}
175
176void CTv::onEvent ( const CTvScanner::ScannerEvent &ev )
177{
178 LOGD ( "%s, CTv::onEvent lockStatus = %d type = %d\n", __FUNCTION__, ev.mLockedStatus, ev.mType );
179
180 if ( mDtvScanRunningStatus == DTV_SCAN_RUNNING_ANALYZE_CHANNEL ) {
181 if ( ev.mType == CTvScanner::ScannerEvent::EVENT_SCAN_END ) {
182 CMessage msg;
183 msg.mType = CTvMsgQueue::TV_MSG_STOP_ANALYZE_TS;
184 msg.mpData = this;
185 mTvMsgQueue.sendMsg ( msg );
186 } else if ( ev.mType == CTvScanner::ScannerEvent::EVENT_STORE_END ) {
187 CTvEpg::EpgEvent epgev;
188 epgev.type = CTvEpg::EpgEvent::EVENT_CHANNEL_UPDATE_END;
189 mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL;
190 sendTvEvent ( epgev );
191 }
192 } else {
193 sendTvEvent ( ev );
194 }
195}
196
197void CTv::onEvent ( const CFrontEnd::FEEvent &ev )
198{
199 LOGD ( "%s, FE event type = %d tvaction=%x", __FUNCTION__, ev.mCurSigStaus, mTvAction);
200 if(mTvAction & TV_ACTION_SCANNING) return;
201
202 //前端事件响应处理
203 if ( ev.mCurSigStaus == CFrontEnd::FEEvent::EVENT_FE_HAS_SIG ) { //作为信号稳定
204 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
205 Vpp_SetDisplayMode ( mVpp.Tv_GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt);
206 if ( m_win_mode == PREVIEW_WONDOW ) {
207 mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2);
208 mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_FULL_STRETCH );
209 }
210
211 if ( m_autoset_displayfreq) {
212 mTvin.VDIN_SetDisplayVFreq ( 50, mAv.getVideoDisplayResolution() , mIsFbc);
213 }
214 TvEvent::SignalInfoEvent ev;
215 ev.mStatus = TVIN_SIG_STATUS_STABLE;
216 ev.mTrans_fmt = TVIN_TFMT_2D;
217 ev.mFmt = TVIN_SIG_FMT_NULL;
218 ev.mReserved = 0;
219 sendTvEvent ( ev );
220 mAv.EnableVideoAuto();
221 mTvAudio.SetAudioMuteForTv ( CC_AUDIO_UNMUTE );
222 }
223 } else if ( ev.mCurSigStaus == CFrontEnd::FEEvent::EVENT_FE_NO_SIG ) { //作为信号消失
224 if(/*m_source_input == SOURCE_TV || */m_source_input == SOURCE_DTV && (mTvAction & TV_ACTION_PLAYING)) { //just playing
225 mAv.DisableVideoWithBlueColor();
226 //
227 TvEvent::SignalInfoEvent ev;
228 ev.mStatus = TVIN_SIG_STATUS_NOSIG;
229 ev.mTrans_fmt = TVIN_TFMT_2D;
230 ev.mFmt = TVIN_SIG_FMT_NULL;
231 ev.mReserved = 0;
232 sendTvEvent ( ev );
233 }
234 }
235
236}
237
238void CTv::onEvent ( const CTvEpg::EpgEvent &ev )
239{
240 switch ( ev.type ) {
241 case CTvEpg::EpgEvent::EVENT_TDT_END:
242 LOGD ( "%s, CTv::onEvent epg time = %ld", __FUNCTION__, ev.time );
243 mTvTime.setTime ( ev.time );
244 break;
245
246 case CTvEpg::EpgEvent::EVENT_CHANNEL_UPDATE: {
247 LOGD ( "%s, CTv:: onEvent channel update", __FUNCTION__ );
248 CMessage msg;
249 msg.mType = CTvMsgQueue::TV_MSG_START_ANALYZE_TS;
250 msg.mpData = this;
251 mCurAnalyzeTsChannelID = ev.channelID;
252 mTvMsgQueue.sendMsg ( msg );
253 break;
254 }
255
256 default:
257 break;
258 }
259
260 sendTvEvent ( ev );
261}
262
263
264void CTv::onEvent(const CAv::AVEvent &ev)
265{
266 LOGD("AVEvent = %d", ev.type);
267 switch ( ev.type ) {
268 case CAv::AVEvent::EVENT_AV_STOP: {
269 break;
270 }
271 case CAv::AVEvent::EVENT_AV_RESUEM: {
272 mAv.EnableVideoAuto();
273 TvEvent::AVPlaybackEvent AvPlayBackEvt;
274 AvPlayBackEvt.mMsgType = TvEvent::AVPlaybackEvent::EVENT_AV_PLAYBACK_RESUME;
275 AvPlayBackEvt.mProgramId = ( int ) ev.param;
276 sendTvEvent(AvPlayBackEvt );
277 break;
278 }
279 case CAv::AVEvent::EVENT_AV_SCAMBLED: {
280 mAv.DisableVideoWithBlueColor();
281 TvEvent::AVPlaybackEvent AvPlayBackEvt;
282 AvPlayBackEvt.mMsgType = TvEvent::AVPlaybackEvent::EVENT_AV_SCAMBLED;
283 AvPlayBackEvt.mProgramId = ( int ) ev.param;
284 sendTvEvent(AvPlayBackEvt );
285 break;
286 }
287 case CAv::AVEvent::EVENT_AV_UNSUPPORT: {
288 LOGD("To AVS or AVS+ format");//just avs format, not unsupport, and avs avs+
289 break;
290 }
291 default:
292 break;
293 }
294}
295
296CTv::CTvMsgQueue::CTvMsgQueue(CTv *tv)
297{
298 mpTv = tv;
299}
300
301CTv::CTvMsgQueue::~CTvMsgQueue()
302{
303}
304
305void CTv::CTvMsgQueue::handleMessage ( CMessage &msg )
306{
307 LOGD ( "%s, CTv::CTvMsgQueue::handleMessage type = %d", __FUNCTION__, msg.mType );
308
309 switch ( msg.mType ) {
310 case TV_MSG_COMMON:
311 break;
312
313 case TV_MSG_STOP_ANALYZE_TS: {
314 //mpTv->Tv_Stop_Analyze_Ts();
315 break;
316 }
317
318 case TV_MSG_START_ANALYZE_TS: {
319 //mpTv->Tv_Start_Analyze_Ts ( pTv->mCurAnalyzeTsChannelID );
320 break;
321 }
322
323 case TV_MSG_CHECK_FE_DELAY: {
324 mpTv->mFrontDev.checkStatusOnce();
325 break;
326 }
327 case TV_MSG_AV_EVENT: {
328 mpTv->onEvent(*((CAv::AVEvent *)(msg.mpPara)));
329 break;
330 }
331 case TV_MSG_FE_EVENT: {
332 mpTv->onEvent(*((CFrontEnd::FEEvent *)(msg.mpPara)));
333 break;
334 }
335 case TV_MSG_SCAN_EVENT: {
336 mpTv->onEvent(*((CTvScanner::ScannerEvent *)(msg.mpPara)));
337 break;
338 }
339 case TV_MSG_EPG_EVENT: {
340 mpTv->onEvent(*((CTvEpg::EpgEvent *)(msg.mpPara)));
341 break;
342 }
343
344 default:
345 break;
346 }
347}
348
349
350void CTv::CTvMsgQueue::onEvent ( const CTvScanner::ScannerEvent &ev )
351{
352 CMessage msg;
353 msg.mDelayMs = 0;
354 msg.mType = CTvMsgQueue::TV_MSG_SCAN_EVENT;
355 memcpy(msg.mpPara, &ev, sizeof(ev));
356 this->sendMsg ( msg );
357}
358
359void CTv::CTvMsgQueue::onEvent ( const CFrontEnd::FEEvent &ev )
360{
361 CMessage msg;
362 msg.mDelayMs = 0;
363 msg.mType = CTvMsgQueue::TV_MSG_FE_EVENT;
364 memcpy(msg.mpPara, &ev, sizeof(ev));
365 this->sendMsg ( msg );
366}
367
368void CTv::CTvMsgQueue::onEvent ( const CTvEpg::EpgEvent &ev )
369{
370 CMessage msg;
371 msg.mDelayMs = 0;
372 msg.mType = CTvMsgQueue::TV_MSG_EPG_EVENT;
373 memcpy(msg.mpPara, &ev, sizeof(ev));
374 this->sendMsg ( msg );
375}
376
377
378void CTv::CTvMsgQueue::onEvent(const CAv::AVEvent &ev)
379{
380 CMessage msg;
381 msg.mDelayMs = 0;
382 msg.mType = CTvMsgQueue::TV_MSG_AV_EVENT;
383 memcpy(msg.mpPara, &ev, sizeof(ev));
384 this->sendMsg ( msg );
385}
386
387int CTv::setTvObserver ( TvIObserver *ob )
388{
389 mpObserver = ob;
390 return 0;
391}
392
393void CTv::sendTvEvent ( const CTvEv &ev )
394{
395 //AutoMutex lock(mLock);
396 /* send sigstate to AutoBackLight */
397 if (ev.getEvType() == CTvEv::TV_EVENT_SIGLE_DETECT) {
398 TvEvent::SignalInfoEvent *pEv = (TvEvent::SignalInfoEvent *)(&ev);
399 if (pEv->mStatus == TVIN_SIG_STATUS_STABLE) {
400 mAutoBackLight.updateSigState(mAutoBackLight.SIG_STATE_STABLE);
401 } else {
402 mAutoBackLight.updateSigState(mAutoBackLight.SIG_STATE_NOSIG);
403 }
404 }
405
406 LOGD ( "%s, tvaction=%x", __FUNCTION__, mTvAction);
407 if((mTvAction & TV_ACTION_SCANNING) && (ev.getEvType() == CTvEv::TV_EVENT_SIGLE_DETECT)) {
408 LOGD("%s, when scanning, not send sig detect event", __FUNCTION__);
409 return;
410 }
411 if ( mpObserver != NULL ) {
412 mpObserver->onTvEvent ( ev );
413 }
414
415 return;
416}
417
418int CTv::ClearAnalogFrontEnd()
419{
420 return mFrontDev.ClearAnalogFrontEnd ();
421}
422
423int CTv::dtvAutoScan()
424{
425 AutoMutex lock ( mLock );
426 mTvAction = mTvAction | TV_ACTION_SCANNING;
427 mTvEpg.leaveChannel();
428 mAv.StopTS ();
429 mAv.DisableVideoWithBlueColor();
430 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_DTV );
431 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_RADIO );
432 CTvEvent::CleanAllEvent();
433 mTvScanner.setObserver ( &mTvMsgQueue );
434 mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL;
435 mFrontDev.Open(FE_DTMB);
436 mTvScanner.autoDtmbScan();//dtmb
437 return 0;
438}
439
440int CTv::dtvCleanProgramByFreq ( int freq )
441{
442 int iOutRet = 0;
443 CTvChannel channel;
444 iOutRet = CTvChannel::SelectByFreq ( freq, channel );
445 if ( -1 == iOutRet ) {
446 LOGD ( "%s, Warnning: Current Freq not have program info in the ts_table\n", __FUNCTION__ );
447 }
448
449 iOutRet == CTvProgram::deleteChannelsProgram ( channel );
450 return iOutRet;
451}
452
453int CTv::dtvManualScan (int beginFreq, int endFreq, int modulation)
454{
455 AutoMutex lock ( mLock );
456 mTvAction = mTvAction | TV_ACTION_SCANNING;
457 mTvEpg.leaveChannel();
458 mAv.StopTS ();
459 mAv.DisableVideoWithBlueColor();
460 CTvChannel::DeleteBetweenFreq(beginFreq, endFreq);
461 mTvScanner.setObserver ( &mTvMsgQueue );
462 mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL;
463 mFrontDev.Open(FE_DTMB);
464 int iOutRet = mTvScanner.manualDtmbScan (beginFreq, endFreq, modulation); //dtmb
465 return iOutRet;
466}
467
468int CTv::dtvAutoScanAtscLock(int attenna, int videoStd, int audioStd)
469{
470 //showboz
471 /* int minScanFreq, maxScanFreq, vStd, aStd;
472 vStd = CC_ATV_VIDEO_STD_PAL;
473 aStd = CC_ATV_AUDIO_STD_DK;
474 v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor(vStd, aStd);
475
476 AutoMutex lock ( mLock );
477 mTvAction = mTvAction | TV_ACTION_SCANNING;
478 mTvEpg.leaveChannel();
479 mAv.StopTS ();
480 mAv.DisableVideoWithBlueColor();
481 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_DTV );
482 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_RADIO );
483 CTvEvent::CleanAllEvent();
484 mTvScanner.setObserver ( &mTvMsgQueue );
485 mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL;
486 mFrontDev.Open(FE_ATSC);
487 mTvScanner.autoAtscScan(CTvScanner::AM_ATSC_ATTENNA_TYPE_AIR, stdAndColor);//dtmb*/
488 return 0;
489}
490
491//searchType 0:not 256 1:is 256 Program
492int CTv::atvAutoScan(int videoStd, int audioStd, int searchType)
493{
494 int minScanFreq, maxScanFreq, vStd, aStd;
495 AutoMutex lock ( mLock );
496 mAv.DisableVideoWithBlueColor();
497 mTvAction = mTvAction | TV_ACTION_SCANNING;
498 mTvScanner.setObserver ( &mTvMsgQueue );
499 mTvAudio.SetAudioMuteForTv ( CC_AUDIO_MUTE );
500 getATVMinMaxFreq (&minScanFreq, &maxScanFreq );
501 if ( minScanFreq == 0 || maxScanFreq == 0 || minScanFreq > maxScanFreq ) {
502 LOGE ( "%s, auto scan freq set is error min=%d, max=%d", __FUNCTION__, minScanFreq, maxScanFreq );
503 return -1;
504 }
505 //if set std null AUTO, use default PAL/DK
506 //if(videoStd == CC_ATV_VIDEO_STD_AUTO) {
507 // vStd = CC_ATV_VIDEO_STD_PAL;
508 // aStd = CC_ATV_AUDIO_STD_DK;
509 //} else {
510 vStd = videoStd;
511 aStd = audioStd;
512 //}
513 tvin_port_t source_port = mTvin.Tvin_GetSourcePortBySourceInput(SOURCE_TV);
514 mTvin.VDIN_OpenPort ( source_port );
515 LOGD("%s, atv auto scan vstd=%d, astd=%d ", __FUNCTION__, vStd, aStd);
516 v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor(vStd, aStd);
517
518 int fmt = CFrontEnd::stdEnumToCvbsFmt (vStd, aStd);
519 mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt );
520 m_cur_set_info_fmt = ( tvin_sig_fmt_t )fmt;
521
522 if (searchType == 0) {
523 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_ATV );
524 } else if (searchType == 1) { //type for skyworth, and insert 256 prog, and just update ts table
525 }
526 minScanFreq = mFrontDev.formatATVFreq ( minScanFreq );
527 maxScanFreq = mFrontDev.formatATVFreq ( maxScanFreq );
528 LOGD("%s, atv auto scan vstd=%d, astd=%d stdandcolor=%lld", __FUNCTION__, vStd, aStd, stdAndColor);
529 mSigDetectThread.setVdinNoSigCheckKeepTimes(1000, false);
530 mFrontDev.Open(FE_ANALOG);
531 mTvScanner.autoAtvScan ( minScanFreq, maxScanFreq, stdAndColor, searchType );
532 return 0;
533}
534
535int CTv::clearAllProgram(int arg0)
536{
537 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_ATV );
538 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_TV );
539 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_DTV );
540 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_RADIO);
541 return 0;
542}
543
544int CTv::atvMunualScan ( int startFreq, int endFreq, int videoStd, int audioStd, int store_Type , int channel_num )
545{
546 int minScanFreq, maxScanFreq, vStd, aStd;
547
548 minScanFreq = mFrontDev.formatATVFreq ( startFreq );
549 maxScanFreq = mFrontDev.formatATVFreq ( endFreq );
550 if ( minScanFreq == 0 || maxScanFreq == 0 ) {
551 LOGE ( "%s, munual scan freq set is error min=%d, max=%d", __FUNCTION__, minScanFreq, maxScanFreq );
552 return -1;
553 }
554
555 //if set std null AUTO, use default PAL/DK
556 //if(videoStd == CC_ATV_VIDEO_STD_AUTO) {
557 // vStd = CC_ATV_VIDEO_STD_PAL;
558 // aStd = CC_ATV_AUDIO_STD_DK;
559 // } else {
560 vStd = videoStd;
561 aStd = audioStd;
562 // }
563
564 AutoMutex lock ( mLock );
565 mAv.DisableVideoWithBlueColor();
566 mTvAction = mTvAction | TV_ACTION_SCANNING;
567 mTvScanner.setObserver ( &mTvMsgQueue );
568
569 mTvAudio.SetAudioMuteForTv ( CC_AUDIO_MUTE );
570 v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor(vStd, aStd);
571
572
573 tvin_port_t source_port = mTvin.Tvin_GetSourcePortBySourceInput(SOURCE_TV);
574 mTvin.VDIN_OpenPort ( source_port );
575
576 int fmt = CFrontEnd::stdEnumToCvbsFmt (vStd, aStd);
577 mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt );
578 m_cur_set_info_fmt = ( tvin_sig_fmt_t )fmt;
579 LOGD("%s, atv manual scan vstd=%d, astd=%d stdandcolor=%lld", __FUNCTION__, videoStd, audioStd, stdAndColor);
580 mFrontDev.Open(FE_ANALOG);
581 return mTvScanner.ATVManualScan ( minScanFreq, maxScanFreq, stdAndColor, store_Type, channel_num);
582}
583
584int CTv::getVideoFormatInfo ( int *pWidth, int *pHeight, int *pFPS, int *pInterlace )
585{
586 int iOutRet = -1;
587 AM_AV_VideoStatus_t video_status;
588
589 do {
590 if ( NULL == pWidth || NULL == pHeight || NULL == pFPS || NULL == pInterlace ) {
591 break;
592 }
593
594 iOutRet = mAv.GetVideoStatus (&video_status );
595
596 if ( AM_SUCCESS != iOutRet ) {
597 LOGD ( "%s, ERROR: Cann't Get video format info\n", __FUNCTION__);
598 break;
599 }
600
601 *pWidth = video_status.src_w;
602 *pHeight = video_status.src_h;
603 *pFPS = video_status.fps;
604 *pInterlace = video_status.interlaced;
605 //LOGD("%s, w : %d h : %d fps : %d interlaced: %d\n", __FUNCTION__, video_status.src_w,video_status.src_h,video_status.fps,video_status.interlaced);
606 } while ( false );
607
608 return iOutRet;
609
610}
611
612int CTv::stopScanLock()
613{
614 AutoMutex lock ( mLock );
615 return stopScan();
616}
617
618int CTv::stopScan()
619{
620 if(!(mTvAction & TV_ACTION_SCANNING)) {
621 LOGD("%s, tv not scanning ,return\n", __FUNCTION__);
622 return 0;
623 }
624 mSigDetectThread.requestAndWaitPauseDetect();
625 mTvEpg.leaveChannel();
626 mTvScanner.stopScan();
627 mFrontDev.Close();
628 mTvAction = mTvAction & ~TV_ACTION_SCANNING;
629 return 0;
630}
631
632int CTv::playProgramLock ( int progId )
633{
634 /* AutoMutex lock ( mLock );
635 CTvProgram prog;
636 int ret = CTvProgram::selectByID ( progId, prog );
637
638 if ( ret != 0 ) {
639 return -1;
640 }
641 int type = prog.getProgType();
642 LOGD ( "%s, blackout = %dprog type = %d id = %d name = %s\n", __FUNCTION__, m_blackout_enable, type, progId, prog.getName().string() );
643 if(m_blackout_enable == 1){
644 mAv.EnableVideoBlackout();
645 }else if(m_blackout_enable == 0){
646 mAv.DisableVideoBlackout();
647 }
648
649 mTvAction = mTvAction | TV_ACTION_PLAYING;
650 m_cur_playing_prog_id = progId;
651 mFrontDev.Open(FE_ANALOG);
652 if ( m_source_input == SOURCE_TV && type == CTvProgram::TYPE_ATV ) {
653 playAtvProgram ( progId );
654 } else if ( m_source_input == SOURCE_DTV && ( type == CTvProgram::TYPE_DTV || type == CTvProgram::TYPE_RADIO ) ) {
655 playDtmbProgram ( progId );
656 } else {
657 LOGD ( "%s, source(%d) != type(%d),not play\n", __FUNCTION__, m_source_input, type );
658 }
659 //just for ui,left/right/stereo
660 setAudioChannel((int)AM_AOUT_OUTPUT_STEREO);*/
661 return 0;
662}
663
664int CTv::playDvbcProgram ( int progId )
665{
666 LOGD ( "%s, progId = %d\n", __FUNCTION__, progId );
667
668 CTvProgram prog;
669 int ret = CTvProgram::selectByID ( progId, prog );
670
671 if ( ret != 0 ) {
672 return -1;
673 }
674
675 LOGD ( "%s, prog name = %s\n", __FUNCTION__, prog.getName().string() );
676 CTvChannel channel;
677 prog.getChannel ( channel );
678
679 mFrontDev.setPara ( channel.getMode(), channel.getFrequency(), channel.getSymbolRate(), channel.getModulation() );
680
681 int vpid = 0x1fff, apid = 0x1fff, vfmt = -1, afmt = -1;
682
683 CTvProgram::Video *pV = prog.getVideo();
684 CTvProgram::Audio *pA;
685
686 if ( pV != NULL ) {
687 vpid = pV->getPID();
688 vfmt = pV->getFormat();
689 }
690
691 int aindex = prog.getCurrentAudio ( String8 ( "eng" ) );
692
693 if ( aindex >= 0 ) {
694 pA = prog.getAudio ( aindex );
695
696 if ( pA != NULL ) {
697 apid = pA->getPID();
698 afmt = pA->getFormat();
699 }
700 }
701 mTvEpg.leaveProgram();
702 mTvEpg.leaveChannel();
703 startPlayTv ( SOURCE_DTV, vpid, apid, vfmt, afmt );
704
705 mTvEpg.enterChannel ( channel.getID() );
706 mTvEpg.enterProgram ( prog.getID() );
707 return 0;
708}
709
710int CTv::getAudioTrackNum ( int progId )
711{
712 int iRet, iOutCnt = 0;
713 CTvProgram prog;
714
715 do {
716 if ( 0 > progId ) {
717 break;
718 }
719
720 iRet = CTvProgram::selectByID ( progId, prog );
721
722 if ( 0 != iRet ) {
723 break;
724 }
725
726 iOutCnt = prog.getAudioTrackSize();
727
728 } while ( false );
729
730 return iOutCnt;
731}
732
733int CTv::getAudioInfoByIndex ( int progId, int idx, int *pAFmt, String8 &lang )
734{
735 int iRet, iOutRet = -1;
736 CTvProgram prog;
737 CTvProgram::Audio *pA = NULL;
738
739 do {
740 if ( NULL == pAFmt || idx < 0 ) {
741 break;
742 }
743
744 iRet = CTvProgram::selectByID ( progId, prog );
745
746 if ( 0 != iRet ) {
747 break;
748 }
749
750 if ( idx >= prog.getAudioTrackSize() ) {
751 break;
752 }
753
754 pA = prog.getAudio ( idx );
755
756 if ( NULL == pA ) {
757 break;
758 }
759
760 *pAFmt = pA->getFormat();
761 lang = pA->getLang();
762 } while ( false );
763
764 return iOutRet;
765}
766
767int CTv::switchAudioTrack ( int progId, int idx )
768{
769 int iOutRet = 0;
770 CTvProgram prog;
771 CTvProgram::Audio *pAudio = NULL;
772 int aPid = -1;
773 int aFmt = -1;
774
775 do {
776 if ( idx < 0 ) {
777 break;
778 }
779
780 iOutRet = CTvProgram::selectByID ( progId, prog );
781
782 if ( 0 != iOutRet ) {
783 break;
784 }
785 if(prog.getAudioTrackSize() <= 1) {
786 LOGD("%s, just one audio track, not to switch", __FUNCTION__);
787 break;
788 }
789 if ( idx >= prog.getAudioTrackSize() ) {
790 break;
791 }
792
793 pAudio = prog.getAudio ( idx );
794
795 if ( NULL == pAudio ) {
796 break;
797 }
798
799 aPid = pAudio->getPID();
800 aFmt = pAudio->getFormat();
801
802 if ( aPid < 0 || aFmt < 0 ) {
803 break;
804 }
805
806 iOutRet = mAv.SwitchTSAudio (( uint16_t ) aPid, ( AM_AV_AFormat_t ) aFmt );
807
808 LOGD ( "%s, iOutRet = %d AM_AV_SwitchTSAudio\n", __FUNCTION__, iOutRet );
809 } while ( false );
810
811 return iOutRet;
812}
813
814int CTv::ResetAudioDecoderForPCMOutput()
815{
816 int iOutRet = 0;
817
818 iOutRet = mAv.ResetAudioDecoder ();
819 LOGD ( "%s, iOutRet = %d AM_AV_ResetAudioDecoder\n", __FUNCTION__, iOutRet );
820 return iOutRet;
821}
822
823int CTv::playDtvProgram ( int mode, int freq, int para1, int para2, int vpid, int vfmt, int apid, int afmt, int pcr)
824{
825
826 mFrontDev.setPara ( mode, freq, para1, para2);
827
828 startPlayTv ( SOURCE_DTV, vpid, apid, vfmt, afmt );
829
830 return 0;
831}
832
833
834int CTv::playDtmbProgram ( int progId )
835{
836 CTvProgram prog;
837 CTvChannel channel;
838 int vpid = 0x1fff, apid = 0x1fff, vfmt = -1, afmt = -1;
839 int aindex;
840 CTvProgram::Audio *pA;
841 CTvProgram::Video *pV;
842 int ret = CTvProgram::selectByID ( progId, prog );
843
844 saveDTVProgramID ( progId );
845 prog.getChannel ( channel );
846 //音量补偿
847 int chanVolCompValue = 0;
848 chanVolCompValue = GetAudioVolumeCompensationVal(progId);
849 SetCurProgramAudioVolumeCompensationVal ( chanVolCompValue );
850
851 mFrontDev.setPara ( channel.getMode(), channel.getFrequency(), channel.getBandwidth(), 0 );
852
853 pV = prog.getVideo();
854
855 if ( pV != NULL ) {
856 vpid = pV->getPID();
857 vfmt = pV->getFormat();
858 }
859
860 aindex = prog.getCurrAudioTrackIndex();
861
862 if ( -1 == aindex ) { //db is default
863 aindex = prog.getCurrentAudio ( String8 ( "eng" ) );
864
865 if ( aindex >= 0 ) {
866 prog.setCurrAudioTrackIndex ( progId, aindex );
867 }
868 }
869
870 if ( aindex >= 0 ) {
871 pA = prog.getAudio ( aindex );
872
873 if ( pA != NULL ) {
874 apid = pA->getPID();
875 afmt = pA->getFormat();
876 }
877 }
878
879 mTvEpg.leaveProgram();
880 mTvEpg.leaveChannel();
881 startPlayTv ( SOURCE_DTV, vpid, apid, vfmt, afmt );
882 mTvEpg.enterChannel ( channel.getID() );
883 mTvEpg.enterProgram ( prog.getID() );
884 return 0;
885}
886
887int CTv::playAtvProgram (int freq, int videoStd, int audioStd, int fineTune)
888{
889 //image selecting channel
890 mSigDetectThread.requestAndWaitPauseDetect();
891 mTvin.Tvin_StopDecoder();
892
893 //set CVBS
894 int fmt = CFrontEnd::stdEnumToCvbsFmt (videoStd, audioStd);
895 mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt );
896 m_cur_set_info_fmt = ( tvin_sig_fmt_t )fmt;
897
898 v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor (videoStd, audioStd);
899 //set TUNER
900 mFrontDev.setPara (FE_ANALOG, freq, stdAndColor, fineTune);
901
902 if ( fineTune != 0 ) {
903 mFrontDev.fineTune ( fineTune / 1000 );
904 }
905
906 mSigDetectThread.initSigState();
907 mSigDetectThread.resumeDetect();
908 return 0;
909}
910
911int CTv::resetFrontEndPara ( frontend_para_set_t feParms )
912{
913 if ( feParms.mode == FE_ANALOG ) {
914 int progID = -1;
915 int tmpFreq = feParms.freq;
916 int tmpfineFreq = feParms.para2;
917 int mode = feParms.mode;
918
919 //get tunerStd from videoStd and audioStd
920 v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor (feParms.videoStd, feParms.audioStd);
921
922 //get program dbID saved by last time,if dbID is -1, it shows program hasn't played
923 progID = getATVProgramID();
924
925 LOGD("%s, resetFrontEndPara- vstd=%d astd=%d stdandcolor=%lld", __FUNCTION__, feParms.videoStd, feParms.audioStd, stdAndColor);
926
927 //judge progID matching db's or not
928 CTvProgram prog;
929
930 if ( CTvProgram::selectByID ( progID, prog ) != 0 ) {
931 LOGE ( "%s, atv progID is not matching the db's\n", __FUNCTION__);
932 return 0;
933 }
934
935 //channel fine tune and save freq, std, fineFreq into DB
936 CTvChannel channel;
937 prog.upDateChannel ( channel, stdAndColor, tmpFreq, tmpfineFreq );
938 mFrontDev.fineTune ( tmpfineFreq / 1000 ); //driver fine tune freq khz
939
940
941 //set frontend parameters to tuner dev
942 mSigDetectThread.requestAndWaitPauseDetect();
943 mTvin.Tvin_StopDecoder();
944
945 //set CVBS
946 int fmt = CFrontEnd::stdEnumToCvbsFmt (feParms.videoStd, feParms.audioStd );
947 mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt );
948 m_cur_set_info_fmt = ( tvin_sig_fmt_t )fmt;
949
950 //set TUNER
951 usleep(400 * 1000);
952 mFrontDev.setPara ( FE_ANALOG, tmpFreq, stdAndColor, tmpfineFreq );
953 usleep(400 * 1000);
954 if ( tmpfineFreq != 0 ) {
955 mFrontDev.fineTune ( tmpfineFreq / 1000 );
956 }
957
958 mSigDetectThread.initSigState();
959 mSigDetectThread.resumeDetect();
960 } else if ( feParms.mode == FE_DTMB ) {
961 mFrontDev.setPara ( FE_DTMB, feParms.freq, feParms.para1, feParms.para2 );
962 }
963
964 return 0;
965}
966
967int CTv::resetDmxAndAvSource()
968{
969 AM_DMX_Source_t curdmxSource;
970 mFrontDev.GetTSSource ( &curdmxSource );
971 LOGD ( "%s, AM_FEND_GetTSSource %d", __FUNCTION__, curdmxSource );
972 mTvDmx.Close();
973 AM_DMX_OpenPara_t para;
974 memset ( &para, 0, sizeof ( para ) );
975 mTvDmx.Open (para);
976 mTvDmx.SetSource(curdmxSource );
977 AM_AV_TSSource_t ts_source = ( AM_AV_TSSource_t ) curdmxSource;
978 mAv.SetTSSource (ts_source );
979 return 0;
980}
981
982int CTv::SetCurProgramAudioVolumeCompensationVal ( int tmpVal )
983{
984 mTvAudio.SetAudioVolumeCompensationVal ( tmpVal );
985 mTvAudio.SetAudioMasterVolume (mTvAudio.GetAudioMasterVolume() );
986
987 LOGD ( "%s, VolumeCompensationVal = %d, id = %d\n", __FUNCTION__, tmpVal, m_cur_playing_prog_id );
988 CTvProgram prog;
989 if ( CTvProgram::selectByID ( m_cur_playing_prog_id, prog ) != 0 ) {
990 LOGE ( "%s, atv progID is not matching the db's ret = 0\n", __FUNCTION__ );
991 return -1;
992 }
993
994 if (prog.updateVolComp ( m_cur_playing_prog_id, tmpVal ) != 0 ) {
995 LOGE ( "%s, atv progID is not matching the db's\n", __FUNCTION__);
996 return -1;
997 }
998 return 0;
999}
1000
1001int CTv::GetAudioVolumeCompensationVal(int progxxId)
1002{
1003 int tmpVolValue = 0;
1004 CTvProgram prog;
1005 if ( CTvProgram::selectByID ( m_cur_playing_prog_id, prog ) != 0 ) {
1006 LOGE ( "%s, atv progID is not matching the db's ret = 0\n", __FUNCTION__ );
1007 return tmpVolValue;
1008 }
1009 tmpVolValue = prog.getChanVolume ();
1010 LOGD ( "%s,progid = %d CompensationVal = %d\n", __FUNCTION__, m_cur_playing_prog_id, tmpVolValue );
1011 if(tmpVolValue > 20 || tmpVolValue < -20) tmpVolValue = 0;
1012 return tmpVolValue;
1013}
1014
1015int CTv::startPlayTv ( int source, int vid, int aid, int vfat, int afat )
1016{
1017 int ret = 0;
1018
1019 if ( source == SOURCE_DTV ) {
1020 AM_FileEcho ( DEVICE_CLASS_TSYNC_AV_THRESHOLD_MIN, AV_THRESHOLD_MIN_MS );
1021 LOGD ( "%s, startPlayTv", __FUNCTION__);
1022 mAv.StartTS (vid, aid, ( AM_AV_VFormat_t ) vfat, ( AM_AV_AFormat_t ) afat );
1023 } else {
1024
1025 }
1026 return ret;
1027}
1028
1029int CTv::stopPlayingLock()
1030{
1031 AutoMutex lock ( mLock );
1032 return stopPlaying();
1033}
1034
1035int CTv::stopPlaying()
1036{
1037 if(!(mTvAction & TV_ACTION_PLAYING)) {
1038 LOGD("%s, stopplay cur action = %x not playing , return", __FUNCTION__, mTvAction);
1039 return 0;
1040 }
1041 mAv.EnableVideoBlackout();
1042 if(m_source_input == SOURCE_TV) {
1043 //first mute
1044 mTvAudio.SetAudioMuteForTv(CC_AUDIO_MUTE);
1045 ClearAnalogFrontEnd();
1046 } else if(m_source_input == SOURCE_DTV) {
1047 //mFrontDev.setPara(FE_DTMB, 51000000, 0, 0);
1048 mAv.StopTS ();
1049 mTvEpg.leaveChannel();
1050 mTvEpg.leaveProgram();
1051 }
1052 mAv.DisableVideoWithBlueColor();
1053 mTvAction = mTvAction & ~TV_ACTION_PLAYING;
1054 return 0;
1055}
1056
1057int CTv::getAudioChannel()
1058{
1059 int iRet = -1;
1060 AM_AOUT_OutputMode_t audioChanneleMod;
1061 do {
1062 iRet = mAv.AudioGetOutputMode (&audioChanneleMod );
1063 if ( AM_SUCCESS != iRet ) {
1064 LOGD ( "%s, jianfei.lan GetOutputMode is FAILED %d\n", __FUNCTION__, iRet );
1065 break;
1066 }
1067 LOGD ( "%s, jianfei.lan getAudioChannel iRet : %d audioChanneleMod %d\n", __FUNCTION__, iRet, audioChanneleMod );
1068 } while ( 0 );
1069 return audioChanneleMod;
1070}
1071
1072int CTv::setAudioChannel ( int channelIdx )
1073{
1074 int iOutRet = 0;
1075 AM_AOUT_OutputMode_t audioChanneleMod;
1076 LOGD ( "%s, channelIdx : %d\n", __FUNCTION__, channelIdx );
1077 audioChanneleMod = ( AM_AOUT_OutputMode_t ) channelIdx;
1078 iOutRet = mAv.AudioSetOutputMode (audioChanneleMod );
1079 if ( AM_SUCCESS != iOutRet) {
1080 LOGD ( "%s, jianfei.lan %s AM_AOUT_SetOutputMode device is FAILED %d\n", __FUNCTION__, "TV", iOutRet );
1081 }
1082 return 0;
1083}
1084
1085int CTv::getFrontendSignalStrength()
1086{
1087 int Strength = 0;
1088 Strength = mFrontDev.getStatus();
1089 return Strength;
1090}
1091
1092int CTv::getFrontendSNR()
1093{
1094 int snr = 0;
1095 snr = mFrontDev.getSNR();
1096 return snr;
1097}
1098
1099int CTv::getFrontendBER()
1100{
1101 int ber = 0;
1102 ber = mFrontDev.getBER();
1103 return ber;
1104
1105}
1106
1107int CTv::getChannelInfoBydbID ( int dbID, channel_info_t &chan_info )
1108{
1109 CTvProgram prog;
1110 CTvChannel channel;
1111 Vector<sp<CTvProgram> > out;
1112 memset ( &chan_info, sizeof ( chan_info ), 0 );
1113 chan_info.freq = 44250000;
1114 chan_info.uInfo.atvChanInfo.videoStd = CC_ATV_VIDEO_STD_PAL;
1115 chan_info.uInfo.atvChanInfo.audioStd = CC_ATV_AUDIO_STD_DK;
1116
1117 int ret = CTvProgram::selectByID ( dbID, prog );
1118 if ( ret != 0 ) {
1119 LOGD ( "getChannelinfo , select dbid=%d,is not exist", dbID);
1120 return -1;
1121 }
1122 prog.getChannel ( channel );
1123
1124 if ( CTvProgram::TYPE_ATV == prog.getProgType() ) {
1125 chan_info.freq = channel.getFrequency();
1126 chan_info.uInfo.atvChanInfo.finefreq = channel.getAfcData();
1127 LOGD("%s, get channel std = %lld", __FUNCTION__, channel.getStd());
1128 chan_info.uInfo.atvChanInfo.videoStd =
1129 ( atv_video_std_t ) CFrontEnd::stdAndColorToVideoEnum ( channel.getStd() );
1130 chan_info.uInfo.atvChanInfo.audioStd =
1131 ( atv_audio_std_t ) CFrontEnd::stdAndColorToAudioEnum ( channel.getStd() );
1132 chan_info.uInfo.atvChanInfo.isAutoStd = ((channel.getStd() & V4L2_COLOR_STD_AUTO) == V4L2_COLOR_STD_AUTO) ? 1 : 0;
1133 } else if ( CTvProgram::TYPE_DTV == prog.getProgType() || CTvProgram::TYPE_RADIO == prog.getProgType()) {
1134 chan_info.freq = channel.getFrequency();
1135 chan_info.uInfo.dtvChanInfo.strength = getFrontendSignalStrength();
1136 chan_info.uInfo.dtvChanInfo.quality = getFrontendSNR();
1137 chan_info.uInfo.dtvChanInfo.ber = getFrontendBER();
1138 }
1139
1140 return 0;
1141}
1142
1143bool CTv::Tv_Start_Analyze_Ts ( int channelID )
1144{
1145 int freq, ret;
1146 CTvChannel channel;
1147
1148 AutoMutex lock ( mLock );
1149 mAv.StopTS ();
1150 mAv.DisableVideoWithBlueColor();
1151 ret = CTvChannel::selectByID ( channelID, channel );
1152
1153 if ( ret != 0 ) {
1154 LOGD ( "%s, CTv tv_updatats can not get freq by channel ID", __FUNCTION__ );
1155 return false;
1156 }
1157
1158 mTvAction = mTvAction | TV_ACTION_SCANNING;
1159 freq = channel.getFrequency();
1160 LOGD ( "%s, the freq = %d", __FUNCTION__, freq );
1161 mDtvScanRunningStatus = DTV_SCAN_RUNNING_ANALYZE_CHANNEL;
1162 mTvScanner.setObserver ( &mTvMsgQueue );
1163 mTvScanner.manualDtmbScan ( freq, freq ); //dtmb
1164 return true;
1165}
1166
1167bool CTv::Tv_Stop_Analyze_Ts()
1168{
1169 stopScanLock();
1170 return true;
1171}
1172
1173
1174int CTv::saveATVProgramID ( int dbID )
1175{
1176 config_set_int ( "TV", "atv.get.program.id", dbID );
1177 return 0;
1178}
1179
1180int CTv::getATVProgramID ( void )
1181{
1182 return config_get_int ( "TV", "atv.get.program.id", -1 );
1183}
1184
1185int CTv::saveDTVProgramID ( int dbID )
1186{
1187 config_set_int ( "TV", "dtv.get.program.id", dbID );
1188 return 0;;
1189}
1190
1191int CTv::getDTVProgramID ( void )
1192{
1193 return config_get_int ( "TV", "dtv.get.program.id", -1 );
1194}
1195
1196int CTv::getATVMinMaxFreq ( int *scanMinFreq, int *scanMaxFreq )
1197{
1198 int tmpVal, i = 0;
1199 const char *config_value;
1200 const char *strDelimit = ",";
1201 char *token = NULL;
1202
1203 *scanMinFreq = 44250000;
1204 *scanMaxFreq = 868250000;
1205
1206 config_value = config_get_str ( "ATV", "atv.get.min.max.freq", "null" );
1207
1208 if ( strcmp ( config_value, "null" ) == 0 ) {
1209 LOGD ( "%s, atv.get.min.max.freq not set config\n", __FUNCTION__ );
1210 return -1;
1211 }
1212
1213 char data_str[512];
1214 memset ( ( void * ) data_str, 0, sizeof ( data_str ) );
1215 strncpy ( data_str, config_value, sizeof ( data_str ) - 1 );
1216
1217 token = strtok ( data_str, strDelimit );
1218 sscanf ( token, "%d", scanMinFreq );
1219 token = strtok ( NULL, strDelimit );
1220
1221 if ( token != NULL ) {
1222 sscanf ( token, "%d", scanMaxFreq );
1223 return 0;
1224 }
1225 return 0;
1226}
1227
1228int CTv::IsDVISignal()
1229{
1230 return ( ( TVIN_SIG_FMT_NULL != mSigDetectThread.getCurSigInfo().fmt ) && ( mSigDetectThread.getCurSigInfo().reserved & 0x1 ) );
1231}
1232
1233int CTv::getHDMIFrameRate()
1234{
1235 int ConstRate[5] = {24, 25, 30, 50, 60};
1236 float ConstRateDiffHz[5] = {0.5, 0.5, 0.5, 2, 2}; //偏差值
1237 int fps = mSigDetectThread.getCurSigInfo().fps;
1238 int i = 0;
1239 for(; i < 5; i++) {
1240 if(abs(ConstRate[i] - fps) < ConstRateDiffHz[i])
1241 fps = ConstRate[i];
1242 }
1243 return fps;
1244}
1245
1246tv_source_input_t CTv::GetLastSourceInput ( void )
1247{
1248 return m_last_source_input;
1249}
1250
1251int CTv::isVgaFmtInHdmi ( void )
1252{
1253 tvin_sig_fmt_t fmt = mSigDetectThread.getCurSigInfo().fmt;
1254
1255 if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI ) {
1256 return -1;
1257 }
1258
1259 return CTvin::isVgaFmtInHdmi ( fmt );
1260}
1261
1262int CTv::SetBypassModulesFor3D ( VIDEO_3D_MODE_E mode )
1263{
1264 LOGD ( "%s, ----> Set mode(%d) <----", __FUNCTION__, mode );
1265 const char *config_value = NULL;
1266
1267 int DIBypassAllFlag = 0;
1268 config_value = config_get_str ( "TV", "tvin.di.bypass_all", "null" );//bypass , if
1269 if (strcasecmp(config_value, "true") == 0 || strcasecmp(config_value, "1") == 0) {
1270 DIBypassAllFlag = 1;
1271 } else {
1272 DIBypassAllFlag = 0;
1273 }
1274
1275
1276 switch (mode) {
1277 case VIDEO_3D_MODE_DISABLE: {
1278 mTvin.VDIN_SetDIBypassAll ( 0 );
1279 mTvin.VDIN_SetDIBypassPost ( 0 );
1280 // mTvin.VDIN_SetDISip_Top_Bot ( 0 );
1281 }
1282 break;
1283 case VIDEO_3D_MODE_AUTO: {
1284 mTvin.VDIN_SetDIBypassAll ( 0 );
1285 mTvin.VDIN_SetDIBypassPost ( 1 );
1286 // mTvin.VDIN_SetDISip_Top_Bot ( 0 );
1287
1288
1289 }
1290 break;
1291 case VIDEO_3D_MODE_LR:
1292 case VIDEO_3D_MODE_TB: {
1293 mTvin.VDIN_SetDIBypassPost ( 1 );
1294 usleep ( 20 * 1000 );
1295 mTvin.VDIN_SetDIBypassAll ( 1 | DIBypassAllFlag );
1296 //mTvin.VDIN_SetDISip_Top_Bot ( 1 );
1297 }
1298 break;
1299 case VIDEO_3D_MODE_LA:
1300 case VIDEO_3D_MODE_FA: {
1301 mTvin.VDIN_SetDIBypassPost ( 1 );
1302 usleep ( 20 * 1000 );
1303 mTvin.VDIN_SetDIBypassAll ( 0 );
1304 //mTvin.VDIN_SetDISip_Top_Bot ( 0 );
1305 }
1306 break;
1307 default:
1308 break;
1309 }
1310
1311 if (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_DTV ) {
1312 if ( mode == VIDEO_3D_MODE_DISABLE ) {
1313 mTvin.VDIN_SetVdinFlag ( MEMP_DCDR_WITHOUT_3D );
1314 } else {
1315 mTvin.VDIN_SetVdinFlag ( MEMP_DCDR_WITH_3D );
1316 }
1317 } else {
1318 if ( mode == VIDEO_3D_MODE_DISABLE ) {
1319 if ( m_source_input == SOURCE_TV ) {
1320 mTvin.VDIN_SetVdinFlag ( MEMP_ATV_WITHOUT_3D );
1321 } else {
1322 mTvin.VDIN_SetVdinFlag ( MEMP_VDIN_WITHOUT_3D );
1323 }
1324 } else {
1325 if ( m_source_input == SOURCE_TV ) {
1326 mTvin.VDIN_SetVdinFlag ( MEMP_ATV_WITH_3D );
1327 } else {
1328 mTvin.VDIN_SetVdinFlag ( MEMP_VDIN_WITH_3D );
1329 }
1330 }
1331 }
1332
1333 return 0;
1334}
1335
1336void CTv::print_version_info ( void )
1337{
1338 // print tvapi version info
1339 LOGD ( "libtvservice git branch:%s\n", tvservice_get_git_branch_info() );
1340 LOGD ( "libtvservice git version:%s\n", tvservice_get_git_version_info() );
1341 LOGD ( "libtvservice Last Changed:%s\n", tvservice_get_last_chaned_time_info() );
1342 LOGD ( "libtvservice Last Build:%s\n", tvservice_get_build_time_info() );
1343 LOGD ( "libtvservice Builer Name:%s\n", tvservice_get_build_name_info() );
1344 LOGD ( "libtvservice board version:%s\n", tvservice_get_board_version_info() );
1345 LOGD ( "\n\n");
1346 // print dvb version info
1347 LOGD ( "libdvb git branch:%s\n", dvb_get_git_branch_info() );
1348 LOGD ( "libdvb git version:%s\n", dvb_get_git_version_info() );
1349 LOGD ( "libdvb Last Changed:%s\n", dvb_get_last_chaned_time_info() );
1350 LOGD ( "libdvb Last Build:%s\n", dvb_get_build_time_info() );
1351 LOGD ( "libdvb Builer Name:%s\n", dvb_get_build_name_info() );
1352}
1353
1354int CTv::Tvin_GetTvinConfig ( void )
1355{
1356 const char *config_value;
1357 int i = 0;
1358
1359 config_value = config_get_str ( "TV", "tvin.overscan.3d", "null" );
1360
1361 if ( strcmp ( config_value, "enable" ) == 0 ) {
1362 gTvinConfig.overscan_3d = 1;
1363 } else {
1364 gTvinConfig.overscan_3d = 0;
1365 }
1366
1367 config_value = config_get_str ( "TV", "tvin.tv.out.counter", "null" );
1368 gTvinConfig.tv_out_counter = ( unsigned int ) strtol ( config_value, NULL, 6 );
1369
1370 if ( gTvinConfig.tv_out_counter <= 0 || gTvinConfig.tv_out_counter > 8 ) {
1371 gTvinConfig.tv_out_counter = 6;
1372 }
1373
1374 config_value = config_get_str ( "TV", "tvin.kernelpet_disable", "null" );
1375
1376 if ( strcmp ( config_value, "disable" ) == 0 ) {
1377 gTvinConfig.kernelpet_disable = true;
1378 } else {
1379 gTvinConfig.kernelpet_disable = false;
1380 }
1381
1382 config_value = config_get_str ( "TV", "tvin.kernelpet.timeout", "null" );
1383 gTvinConfig.userpet_timeout = ( unsigned int ) strtol ( config_value, NULL, 10 );
1384
1385 if ( gTvinConfig.kernelpet_timeout <= 0 || gTvinConfig.kernelpet_timeout > 40 ) {
1386 gTvinConfig.kernelpet_timeout = 10;
1387 }
1388
1389
1390 config_value = config_get_str ( "TV", "tvin.userpet", "null" );
1391
1392 if ( strcmp ( config_value, "enable" ) == 0 ) {
1393 gTvinConfig.userpet = true;
1394 } else {
1395 gTvinConfig.userpet = false;
1396 }
1397
1398 config_value = config_get_str ( "TV", "tvin.userpet.timeout", "null" );
1399 gTvinConfig.userpet_timeout = ( unsigned int ) strtol ( config_value, NULL, 10 );
1400
1401 if ( gTvinConfig.userpet_timeout <= 0 || gTvinConfig.userpet_timeout > 100 ) {
1402 gTvinConfig.userpet_timeout = 10;
1403 }
1404
1405 config_value = config_get_str ( "TV", "tvin.userpet.reset", "null" );
1406
1407 if ( strcmp ( config_value, "disable" ) == 0 ) {
1408 gTvinConfig.userpet_reset = 0;
1409 } else {
1410 gTvinConfig.userpet_reset = 1;
1411 }
1412
1413 config_value = config_get_str ( "TV", "tvin.title_shake", "null" );
1414
1415 if ( strcmp ( config_value, "enable" ) == 0 ) {
1416 gTvinConfig.title_shake = true;
1417 } else {
1418 gTvinConfig.title_shake = false;
1419 }
1420
1421 return 0;
1422}
1423
1424int CTv::SetAudioMainVolLutBufName()
1425{
1426 int i = 0;
1427 const char *tmp_ptr = NULL;
1428 int get_type_buf[6] = { CC_GET_LUT_TV, CC_GET_LUT_AV, CC_GET_LUT_COMP, CC_GET_LUT_HDMI, CC_GET_LUT_VGA, CC_GET_LUT_MPEG };
1429 const char *end_str_buf[6] = { ".tv", ".av", ".comp", ".hdmi", ".vga", ".mpeg", };
1430 project_info_t tmp_info;
1431 char tmp_buf[128];
1432 char value_buf[128];
1433 char key_buf[128];
1434
1435 int name_en = GetAudioMainVolLutBufNameModifyEnableCFG();
1436
1437 if (name_en == 1) {
1438 strcpy(tmp_buf, "null");
1439 if (GetProjectInfo(&tmp_info) == 0) {
1440 strncpy(tmp_buf, tmp_info.amp_curve_name, CC_PROJECT_INFO_ITEM_MAX_LEN - 1);
1441 }
1442
1443 if (strcmp(tmp_buf, "null") != 0) {
1444 for ( i = 0; i < 6; i++ ) {
1445 memset(value_buf, '\0', sizeof(value_buf));
1446 memset(key_buf, '\0', sizeof(key_buf));
1447
1448 GetAudioMainVolLutBufNameCFG(get_type_buf[i], key_buf);
1449
1450 strcpy(value_buf, tmp_buf);
1451 strcat(value_buf, end_str_buf[i]);
1452
1453 tmp_ptr = config_get_str("TV", key_buf, "null");
1454 if (strcmp(tmp_ptr, value_buf) != 0) {
1455 config_set_str("TV", key_buf, value_buf);
1456 LOGD("%s, config string now set as: %s \n", __FUNCTION__, value_buf);
1457 } else {
1458 LOGD("%s, config string has been set as: %s \n", __FUNCTION__, value_buf);
1459 }
1460 }
1461 }
1462 }
1463
1464 return 0;
1465}
1466
1467int CTv::SetAudioSupperBassVolLutBufName()
1468{
1469 int i = 0;
1470 const char *tmp_ptr = NULL;
1471 int get_type_buf[6] = { CC_GET_LUT_TV, CC_GET_LUT_AV, CC_GET_LUT_COMP, CC_GET_LUT_HDMI, CC_GET_LUT_VGA, CC_GET_LUT_MPEG };
1472 const char *end_str_buf[6] = { ".tv", ".av", ".comp", ".hdmi", ".vga", ".mpeg", };
1473 project_info_t tmp_info;
1474 char tmp_buf[128];
1475 char value_buf[128];
1476 char key_buf[128];
1477
1478 int name_en = GetAudioSupperBassVolLutBufNameModifyEnableCFG();
1479
1480 if (name_en == 1) {
1481 strcpy(tmp_buf, "null");
1482 if (GetProjectInfo(&tmp_info) == 0) {
1483 strncpy(tmp_buf, tmp_info.amp_curve_name, CC_PROJECT_INFO_ITEM_MAX_LEN - 1);
1484 }
1485
1486 if (strcmp(tmp_buf, "null") != 0) {
1487 for ( i = 0; i < 6; i++ ) {
1488 memset(value_buf, '\0', sizeof(value_buf));
1489 memset(key_buf, '\0', sizeof(key_buf));
1490
1491 GetAudioSupperBassVolLutBufNameCFG(get_type_buf[i], key_buf);
1492
1493 strcpy(value_buf, tmp_buf);
1494 strcat(value_buf, ".sup");
1495 strcat(value_buf, end_str_buf[i]);
1496
1497 tmp_ptr = config_get_str("TV", key_buf, "null");
1498 if (strcmp(tmp_ptr, value_buf) != 0) {
1499 config_set_str("TV", key_buf, value_buf);
1500 LOGD("%s, config string now set as: %s \n", __FUNCTION__, value_buf);
1501 } else {
1502 LOGD("%s, config string has been set as: %s \n", __FUNCTION__, value_buf);
1503 }
1504 }
1505 }
1506 }
1507
1508 return 0;
1509}
1510
1511TvRunStatus_t CTv::GetTvStatus()
1512{
1513 return mTvStatus;
1514}
1515
1516int CTv::OpenTv ( void )
1517{
1518 int tmp_val = 0;
1519 const char *value;
1520 //reboot system by fbc setting.
1521 value = config_get_str ( "TV", "fbc.get.panelinfo", "null" );
1522 LOGD("%s fbc-------------------\n", value);
1523 if ( strcmp ( value, "edid" ) == 0 ) {
1524 if(reboot_sys_by_fbc_edid_info() == 0) {
1525 }
1526 } else if ( strcmp ( value, "uart" ) == 0 ) {
1527 if(reboot_sys_by_fbc_uart_panel_info() == 0) {
1528 }
1529 }
1530
1531 LOGD ( "%s, tv open\n", __FUNCTION__);
1532 char prop_value[PROPERTY_VALUE_MAX];
1533 memset ( prop_value, '\0', PROPERTY_VALUE_MAX );
1534
1535 mTvin.Tvin_LoadSourceInputToPortMap();
1536
1537 SSMSave3DLRSwitch ( 0 );
1538 SSMSave3DTO2D ( 0 );
1539 //
1540 SSMHandlePreCopying();
1541 if ( SSMDeviceMarkCheck() < 0 ) {
1542 SSMRestoreDeviceMarkValues();
1543 Tv_SSMRestoreDefaultSetting();
1544 }
1545 mTvin.OpenTvin();
1546 mTvin.init_vdin();
1547 mTvin.Tv_init_afe();
1548 mVpp.Vpp_Init();
1549 SetAudioSupperBassVolLutBufName();
1550 SetAudioMainVolLutBufName();
1551 mTvAudio.AudioCtlInitializeLoad();
1552
1553 SSMSetHDCPKey();
1554 system ( "/system/bin/dec" );
1555
1556 //set color filter
1557 // SetFileAttrValue ( "/sys/module/amvideo/parameters/filt_mode", "0x2100" );
1558
1559 if ( gTvinConfig.title_shake) {
1560 SetFileAttrValue ( "/sys/module/di/parameters/di_new_mode_mask", "0x10000" );
1561 }
1562
1563 value = config_get_str ( "TV", "tvin.autoset.displayfreq", "null" );
1564
1565 if ( strcmp ( value, "enable" ) == 0 ) {
1566 m_autoset_displayfreq = true;
1567 } else {
1568 m_autoset_displayfreq = false;
1569 }
1570
1571 if (mTvin.VDIN_GetDisplayVFreq() == 30) {
1572 m_autoset_displayfreq = false;
1573 }
1574
1575 if (GetPlatformHaveDDFlag() == 1) {
1576 SetFileAttrValue ("/sys/module/tvin_hdmirx/parameters/edid_mode", "0x109");
1577 }
1578
1579 value = config_get_str ( "TV", "ssm.handle.hdmi.edid.en", "null" );
1580
1581 if ( strtoul(value, NULL, 10) == 1 ) {
1582 LOGD( "%s, get config \"%s\" is \"%s\".\n",
1583 __FUNCTION__, "ssm.handle.hdmi.edid.en", value );
1584 //get hdmi edid use mode
1585 char prop_value[256];
1586 memset( prop_value, '\0', 256 );
1587 property_get( "ubootenv.var.outputmode", prop_value, "null" );
1588 LOGD( "%s, get property \"%s\" is \"%s\".\n",
1589 __FUNCTION__, "ubootenv.var.outputmode", prop_value );
1590 if ( strcmp ( prop_value, "null" ) != 0 ) {
1591 config_set_str ( "TV", "ssm.handle.hdmi.edid.use", prop_value );
1592 int i;
1593 char edid_path[256];
1594 char edid_path_cfg[256];
1595 //set file's path for hdmi edid of each port
1596 for ( i = 1; i <= SSM_HDMI_PORT_MAX; i++ ) {
1597 memset( edid_path, '\0', 256 );
1598 memset( edid_path_cfg, '\0', 256 );
1599 sprintf ( edid_path, "/system/etc/%s_port%d.bin", prop_value, i );
1600 sprintf ( edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i );
1601 config_set_str ( "TV", edid_path_cfg, edid_path );
1602 }
1603 } else {
1604 //set default hdmi edid
1605 config_set_str ( "TV", "ssm.handle.hdmi.edid.use", "hdmi_edid" );
1606 int i;
1607 char edid_path[256];
1608 char edid_path_cfg[256];
1609 //set file's path for hdmi edid of each port
1610 for ( i = 1; i <= SSM_HDMI_PORT_MAX; i++ ) {
1611 memset( edid_path, '\0', 256 );
1612 memset( edid_path_cfg, '\0', 256 );
1613 sprintf ( edid_path, "/system/etc/%s_port%d.bin", "hdmi_edid", i );
1614 sprintf ( edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i );
1615 config_set_str ( "TV", edid_path_cfg, edid_path );
1616 }
1617 }
1618 m_is_set_hdmi_edid = true;
1619 }
1620 //
1621 unsigned char val = 0;
1622 Tvin_GetTvinConfig();
1623 m_last_source_input = SOURCE_INVALID;
1624 m_source_input = SOURCE_INVALID;
1625 m_mode_3d = VIDEO_3D_MODE_DISABLE;
1626 m_is_hdmi_sr_detect_start = false;
1627 m_hdmi_sampling_rate = 0;
1628 int8_t blackout_enable;
1629 SSMReadBlackoutEnable(&blackout_enable);
1630 m_blackout_enable = blackout_enable;
1631
1632
1633 //
1634 //dtv init
1635 int rt = -1;
1636 //opendemux();
1637 rt = mFrontDev.Open(FE_ANALOG);
1638 mFrontDev.autoLoadFE();
1639 AM_DMX_OpenPara_t para_dmx;
1640 memset ( &para_dmx, 0, sizeof ( AM_DMX_OpenPara_t ) );
1641 mTvDmx.Open(para_dmx );
1642 mTvDmx.SetSource (AM_DMX_SRC_TS2);
1643 mAv.Open();
1644 mTvEpg.Init ( 0, 0, 1, "eng zho chi", "GB2312" );
1645 resetDmxAndAvSource();
1646 mSourceConnectDetectThread.startDetect();
1647
1648 if (SSMReadSerialCMDSwitchValue() == 1) {
1649 SetSerialSwitch(SERIAL_A, 1);
1650 }
1651 mTvin.VDIN_SetVdinFlag ( MEMP_DCDR_WITHOUT_3D );
1652 mTvin.VDIN_SetMVCViewMode(0);//for not 3d screen
1653 ClearAnalogFrontEnd();
1654
1655 mTvStatus = TV_OPEN_ED;
1656
1657 mHDMIRxCEC.start();
1658
1659 return 0;
1660}
1661
1662int CTv::CloseTv ( void )
1663{
1664 LOGD ( "tv close");
1665 mSigDetectThread.stopDetect();
1666 if (mpUpgradeFBC != NULL) {
1667 mpUpgradeFBC->stop();
1668 }
1669 mTvin.Tv_uninit_afe();
1670 mTvin.uninit_vdin();
1671 mVpp.Vpp_Uninit();
1672 TvMisc_DisableWDT ( gTvinConfig.userpet );
1673 mTvStatus = TV_CLOSE_ED;
1674 return 0;
1675}
1676
1677
1678int CTv::StartTvLock ()
1679{
1680 LOGD ( "%s, tv start status = %d", __FUNCTION__, mTvStatus);
1681 if(mTvStatus == TV_START_ED)
1682 return 0;
1683
1684 Mutex::Autolock _l ( mLock );
1685 mTvAction = mTvAction | TV_ACTION_STARTING;
1686 mTvAudio.SwitchAVOutBypass(0);
1687 mTvAudio.AudioCtlInit();
1688 mFrontDev.Open(FE_ANALOG);
1689 mSigDetectThread.startDetect();
1690 mSigDetectThread.pauseDetect();
1691 mSigDetectThread.initSigState();
1692 mTvMsgQueue.startMsgQueue();
1693 resetDmxAndAvSource();
1694 Vpp_SetDisplayMode ( mVpp.Tv_GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt);
1695 TvMisc_EnableWDT ( gTvinConfig.kernelpet_disable, gTvinConfig.userpet, gTvinConfig.kernelpet_timeout, gTvinConfig.userpet_timeout, gTvinConfig.userpet_reset );
1696 am_phase_t am_phase;
1697 if (mVpp.getPqData()->PQ_GetPhaseArray ( &am_phase ) == 0 ) {
1698 mTvin.TvinApi_SetCompPhase(am_phase);
1699 }
1700 mTvin.TvinApi_SetCompPhaseEnable ( 1 );
1701 mTvin.VDIN_EnableRDMA ( 1 );
1702 mTvin.VDIN_SetDIBypasshd ( 0 );
1703
1704 SetBypassModulesFor3D ( VIDEO_3D_MODE_DISABLE );
1705 //win pos
1706 tvin_window_pos_t win_pos;
1707 Vpp_GetDisplayResolutionInfo(&win_pos);
1708 SetPreviewWindow ( win_pos );
1709
1710 mTvin.Tvin_RemovePath ( TV_PATH_TYPE_TVIN );
1711 if ( mTvin.Tvin_RemovePath ( TV_PATH_TYPE_DEFAULT ) ) {
1712 mTvin.Tvin_AddPath ( TV_PATH_DECODER_NEW3D_WITHOUTPPMGR_AMVIDEO );
1713 }
1714 mTvin.VDIN_SetVdinFlag ( MEMP_DCDR_WITHOUT_3D );
1715
1716 mAv.SetVideoWindow (0, 0, 0, 0 );
1717
1718 mTvAction = mTvAction & ~TV_ACTION_STARTING;
1719 mTvStatus = TV_START_ED;
1720 return 0;
1721}
1722int CTv::StopTvLock ( void )
1723{
1724 LOGD("%s, call Tv_Stop status = %d \n", __FUNCTION__, mTvStatus);
1725 const char *value;
1726 Mutex::Autolock _l ( mLock );
1727 //we should stop audio first for audio mute.
1728 mTvAction = mTvAction | TV_ACTION_STOPING;
1729 mSigDetectThread.requestAndWaitPauseDetect();
1730 mAv.EnableVideoBlackout();
1731 //stop scan if scanning
1732 if(mTvAction & TV_ACTION_SCANNING) {
1733 LOGD("%s, scanning first stop it\n", __FUNCTION__)
1734 mTvEpg.leaveChannel();
1735 mTvScanner.stopScan();
1736 mTvAction = mTvAction & ~TV_ACTION_SCANNING;
1737 }
1738 //first stop play(if playing)
1739 stopPlaying();
1740 //
1741 mTvAudio.SwitchAVOutBypass(0);
1742 tv_audio_channel_e audio_channel = mTvin.Tvin_GetInputSourceAudioChannelIndex (SOURCE_MPEG);
1743 mTvAudio.AudioLineInSelectChannel( audio_channel );
1744 mTvAudio.AudioCtlUninit();
1745 mTvin.Tvin_StopDecoder();
1746 mTvin.Tvin_RemovePath ( TV_PATH_TYPE_TVIN );
1747 Tv_Set3DMode(VIDEO_3D_MODE_DISABLE);
1748 mTvAudio.SetAudioMuteForTv ( CC_AUDIO_UNMUTE );
1749 tvin_window_pos_t win_pos;
1750 Vpp_GetDisplayResolutionInfo(&win_pos);
1751 SetPreviewWindow (win_pos );
1752 mVpp.Tv_LoadVppSettings ( SOURCE_TYPE_MPEG, TVIN_SIG_FMT_NULL, INDEX_2D, TVIN_TFMT_2D );
1753 Vpp_SetDisplayMode ( mVpp.Tv_GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(SOURCE_MPEG) ), CTvin::Tvin_SourceInputToSourceInputType(SOURCE_MPEG), mSigDetectThread.getCurSigInfo().fmt);
1754 RefreshAudioMasterVolume ( SOURCE_MPEG );
1755 mVpp.VPP_SetVideoCrop ( 0, 0, 0, 0 );
1756 m_last_source_input = SOURCE_INVALID;
1757 m_source_input = SOURCE_INVALID;
1758 mAv.DisableVideoWithBlackColor();
1759 mAv.ClearVideoBuffer();
1760 mFrontDev.Close();
1761 mTvAction = mTvAction & ~TV_ACTION_STOPING;
1762 mTvStatus = TV_STOP_ED;
1763 value = config_get_str ( "TV", "tvin.2d4G.headset.en", "null" );
1764 if ( strcmp ( value, "enable" ) == 0 ) {
1765 property_set("audio.tv_open.flg", "0");
1766 }
1767
1768 Tv_SetDDDRCMode(SOURCE_MPEG);
1769 return 0;
1770}
1771
1772int CTv::Tv_MiscSetBySource ( tv_source_input_t source_input )
1773{
1774 int ret = -1;
1775
1776 switch ( source_input ) {
1777 case SOURCE_TV:
1778 ret = SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "4" );
1779 break;
1780
1781 case SOURCE_HDMI1:
1782 case SOURCE_HDMI2:
1783 case SOURCE_HDMI3:
1784 //ret = mVpp.Tv_SavePanoramaMode ( VPP_PANORAMA_MODE_FULL, SOURCE_TYPE_HDMI );
1785 ret |= SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "5" );
1786 break;
1787
1788 case SOURCE_DTV:
1789 if ( m_autoset_displayfreq) {
1790 ret = mTvin.VDIN_SetDisplayVFreq ( 50, mAv.getVideoDisplayResolution() , mIsFbc);
1791 }
1792
1793 case SOURCE_AV1:
1794 case SOURCE_AV2:
1795 case SOURCE_VGA:
1796 ret |= SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "5" );
1797 break;
1798
1799 case SOURCE_SVIDEO:
1800 case SOURCE_IPTV:
1801 default:
1802 ret |= SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "5" );
1803 break;
1804 }
1805
1806 return ret;
1807}
1808
1809int CTv::SetSourceSwitchInput (tv_source_input_t source_input )
1810{
1811 Mutex::Autolock _l ( mLock );
1812 LOGD ( "%s, source input = %d", __FUNCTION__, source_input );
1813 tv_source_input_t cur_source_input = m_source_input;
1814 tvin_port_t cur_port;
1815
1816 Tv_SetDDDRCMode(source_input);
1817
1818 if (source_input == cur_source_input ) {
1819 LOGW ( "%s,same input change display mode", __FUNCTION__ );
1820 return 0;
1821 }
1822
1823 //if HDMI, need to set EDID of each port
1824 if (m_is_set_hdmi_edid) {
1825 int tmp_ret = 0;
1826 switch ( source_input ) {
1827 case SOURCE_HDMI1:
1828 tmp_ret = SSMSetHDMIEdid(1);
1829 break;
1830 case SOURCE_HDMI2:
1831 tmp_ret = SSMSetHDMIEdid(2);
1832 break;
1833 case SOURCE_HDMI3:
1834 tmp_ret = SSMSetHDMIEdid(3);
1835 break;
1836 default:
1837 tmp_ret = -1;
1838 break;
1839 }
1840 if (tmp_ret < 0)
1841 LOGE ( "%s, do not set hdmi port%d edid.ret=%d", __FUNCTION__, source_input - 4, tmp_ret );
1842 }
1843 mTvAction = mTvAction | TV_ACTION_SOURCE_SWITCHING;
1844 m_cur_playing_prog_id = -1;
1845 //
1846 CMessage msg;
1847 msg.mType = CTvMsgQueue::TV_MSG_CHECK_FE_DELAY;
1848 msg.mpData = this;
1849 msg.mDelayMs = 3500;//ms
1850 mTvMsgQueue.removeMsg ( msg );
1851 //mute first
1852 mTvAudio.SetAudioMuteForTv(CC_AUDIO_MUTE);
1853 mSigDetectThread.requestAndWaitPauseDetect();
1854 mAv.DisableVideoWithBlueColor();
1855 //enable blackout, when play,disable it
1856 mAv.EnableVideoBlackout();
1857 //set front dev mode
1858 if ( source_input == SOURCE_TV ) {
1859 mFrontDev.Close();
1860 mFrontDev.Open(FE_ANALOG);
1861 //mFrontDev.setMode ( FE_ANALOG );
1862 } else if ( source_input == SOURCE_DTV ) {
1863 mFrontDev.Close();
1864 mFrontDev.Open(FE_ANALOG);
1865 //mFrontDev.setMode ( FE_DTMB);
1866 } else {
1867 mFrontDev.Close();
1868 }
1869
1870 //ok
1871 m_last_source_input = m_source_input;
1872 m_source_input = source_input;
1873 SSMSaveSourceInput ( source_input );
1874
1875 tv_source_input_t pre_source_input = cur_source_input;//change
1876 cur_source_input = source_input;
1877
1878 mTvAudio.SetAudioVolumeCompensationVal ( 0 );
1879
1880 if ( source_input == SOURCE_DTV ) {
1881 //we should stop audio first for audio mute.
1882 mTvAudio.SwitchAVOutBypass(0);
1883 tv_audio_channel_e audio_channel = mTvin.Tvin_GetInputSourceAudioChannelIndex (SOURCE_MPEG);
1884 mTvAudio.AudioLineInSelectChannel( audio_channel );
1885 mTvAudio.AudioCtlUninit();
1886 //
1887 mTvin.Tvin_StopDecoder();
1888 mTvin.Tvin_RemovePath ( TV_PATH_TYPE_TVIN );
1889 Tv_Set3DMode(VIDEO_3D_MODE_DISABLE);
1890 //double confirm we set the main volume lut buffer to mpeg
1891 RefreshAudioMasterVolume ( SOURCE_MPEG );
1892 mTvAudio.AudioDataInitForDtv();
1893 mTvin.setMpeg2Vdin(1);
1894 mVpp.Tv_LoadVppSettings ( SOURCE_TYPE_DTV, TVIN_SIG_FMT_NULL, INDEX_2D, TVIN_TFMT_2D );
1895 } else {
1896 mTvin.setMpeg2Vdin(0);
1897 mTvin.Tvin_AddPath ( TV_PATH_VDIN_NEW3D_WITHOUTPPMGR_AMVIDEO );
1898 mTvin.VDIN_SetVdinFlag ( MEMP_VDIN_WITHOUT_3D );
1899 }
1900 cur_port = mTvin.Tvin_GetSourcePortBySourceInput ( cur_source_input );
1901 Tv_MiscSetBySource ( source_input );
1902
1903 //only DTV->TVIN or TVIN->DTV need start resource detect thread
1904 if ( ( pre_source_input == SOURCE_DTV || cur_source_input == SOURCE_DTV ) && ( cur_source_input != pre_source_input ) ) {
1905 LOGD ( "%s, dtv need resource detect\n", __FUNCTION__ );
1906 int isNeedCheckD2D3 = ( gTvinConfig.memory512m) ? 1 : 0;
1907 static int sigchkcnt = 0;
1908 while ( true ) {
1909 if ( ( mTvin.Tvin_CheckPathActive ( TV_PATH_TYPE_DEFAULT, isNeedCheckD2D3 ) == TV_PATH_STATUS_INACTIVE )
1910 && ( mTvin.Tvin_CheckPathActive ( TV_PATH_TYPE_TVIN, isNeedCheckD2D3 ) == TV_PATH_STATUS_INACTIVE ) ) {
1911 LOGD("%s, path check is ok, and break\n", __FUNCTION__)
1912 break;
1913 } else {
1914 if(sigchkcnt++ > 20) {
1915 sigchkcnt = 0;
1916 break;
1917 }
1918
1919 LOGW ( "%s,resource is busy.", __FUNCTION__);
1920 }
1921 }//while
1922 }//if need check,and check return
1923
1924 if ( source_input != SOURCE_DTV ) {
1925 // Uninit data
1926 mTvAudio.AudioDataUnInit();
1927 if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3 ||
1928 source_input == SOURCE_MPEG || source_input == SOURCE_DTV ) {
1929 mTvAudio.SwitchAVOutBypass(0);
1930 } else {
1931 mTvAudio.SwitchAVOutBypass(1);
1932 }
1933
1934 tv_audio_channel_e audio_channel = mTvin.Tvin_GetInputSourceAudioChannelIndex (source_input);
1935 mTvAudio.AudioLineInSelectChannel( audio_channel );
1936
1937 Tv_SetAudioInSource ( source_input );
1938 if ( source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3 ) {
1939 m_is_hdmi_sr_detect_start = true;
1940 m_hdmi_sampling_rate = 0;
1941 } else {
1942 mTvAudio.AudioDataInit ( 48000, true );
1943 audio_sr = 48000;
1944 }
1945 //===========================================
1946 if ( mTvin.SwitchPort ( cur_port ) == 0 ) { //ok
1947 //==========================================
1948 SSMSave3DDepth ( 0 );
1949 mTvin.Tvin_SetDepthOf2Dto3D ( 0 ); // set default depth
1950 Tv_Set3DMode(VIDEO_3D_MODE_DISABLE);
1951 SSMSave3DLRSwitch ( 0 );
1952 SSMSave3DTO2D (0);
1953
1954 //for HDMI source connect detect
1955 mTvin.VDIN_OpenHDMIPinMuxOn(true);
1956 mTvAudio.AudioSetRecordDataZero ( false ); //make AudioRecord data avaliable
1957 mVpp.Vpp_ResetLastVppSettingsSourceType();
1958 //==========================================
1959 m_sig_stable_nums = 0;
1960 mSigDetectThread.initSigState();
1961 if(source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) {
1962 mSigDetectThread.setVdinNoSigCheckKeepTimes(5000, true);
1963 } else {
1964 mSigDetectThread.setVdinNoSigCheckKeepTimes(3000, true);
1965 }
1966 mSigDetectThread.resumeDetect();
1967 } else {
1968 }
1969 }
1970
1971 Tv_SetAudioSourceType(source_input);
1972 RefreshAudioMasterVolume(source_input);
1973 Tv_SetAudioOutputSwap_Type(source_input);
1974
1975 mTvAction = mTvAction & ~ TV_ACTION_SOURCE_SWITCHING;
1976 return 0;
1977}
1978
1979void CTv::onSigToStable()
1980{
1981 if ( ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_TV ) ) {
1982 mSigDetectThread.getCurSigInfo().fmt = m_cur_set_info_fmt;
1983 }
1984 if ( m_autoset_displayfreq) {
1985 if ( CTvin::Tvin_is50HzFrameRateFmt ( mSigDetectThread.getCurSigInfo().fmt ) ) {
1986 mTvin.VDIN_SetDisplayVFreq ( 50, mAv.getVideoDisplayResolution(), mIsFbc );
1987 LOGD ( "%s, SetDisplayVFreq 50HZ.", __FUNCTION__);
1988 } else {
1989 mTvin.VDIN_SetDisplayVFreq ( 60, mAv.getVideoDisplayResolution(), mIsFbc );
1990 LOGD ( "%s, SetDisplayVFreq 60HZ.", __FUNCTION__);
1991 }
1992 }
1993 //showbo mark hdmi auto 3d, tran fmt is 3d, so switch to 3d
1994 LOGD("hdmi trans_fmt = %d", mSigDetectThread.getCurSigInfo().trans_fmt);
1995 if (mSigDetectThread.getCurSigInfo().trans_fmt != TVIN_TFMT_2D) {
1996 Tv_Set3DMode(VIDEO_3D_MODE_AUTO);
1997 }
1998
1999 LOGD("onSigToStable --- trans_fmt = %d", mSigDetectThread.getCurSigInfo().trans_fmt);
2000 //load pq parameters
2001 mVpp.Tv_LoadVppSettings (CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt );
2002
2003 if ( m_win_mode == PREVIEW_WONDOW ) {
2004 mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2);
2005 mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_FULL_STRETCH );
2006 } else {
2007 Vpp_SetDisplayMode ( mVpp.Tv_GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt);
2008 }
2009 m_sig_stable_nums = 0;
2010
2011}
2012void CTv::onSigStableToUnstable()
2013{
2014 LOGD ( "%s, stable to unstable\n", __FUNCTION__);
2015 mTvAudio.SetAudioMuteForTv(CC_AUDIO_MUTE);
2016 mAv.DisableVideoWithBlackColor();
2017 mTvin.Tvin_StopDecoder();
2018}
2019void CTv::onSigStableToUnSupport()
2020{
2021 mTvAudio.SetAudioMuteForTv(CC_AUDIO_MUTE);
2022 mAv.DisableVideoWithBlackColor();
2023 mTvin.Tvin_StopDecoder();
2024
2025 tvin_info_t info = mSigDetectThread.getCurSigInfo();
2026 TvEvent::SignalInfoEvent ev;
2027 ev.mTrans_fmt = info.trans_fmt;
2028 ev.mFmt = info.fmt;
2029 ev.mStatus = info.status;
2030 ev.mReserved = info.reserved;
2031 sendTvEvent ( ev );
2032 LOGD ( "%s, Enable blackscreen for signal change in StableToUnSupport!", __FUNCTION__ );
2033}
2034void CTv::onSigStableToNoSig()
2035{
2036 mTvAudio.SetAudioMuteForTv(CC_AUDIO_MUTE);
2037 mAv.DisableVideoWithBlueColor();
2038 //SetAudioMuteForTv(CC_AUDIO_MUTE);
2039 mTvin.Tvin_StopDecoder();
2040
2041 tvin_info_t info = mSigDetectThread.getCurSigInfo();
2042 TvEvent::SignalInfoEvent ev;
2043 ev.mTrans_fmt = info.trans_fmt;
2044 ev.mFmt = info.fmt;
2045 ev.mStatus = info.status;
2046 ev.mReserved = info.reserved;
2047 sendTvEvent ( ev );
2048 LOGD ( "%s, Enable bluescreen for signal change in StableToNoSig!", __FUNCTION__);
2049}
2050void CTv::onSigUnStableToUnSupport()
2051{
2052 mAv.DisableVideoWithBlackColor();
2053 mTvin.Tvin_StopDecoder();
2054 tvin_info_t info = mSigDetectThread.getCurSigInfo();
2055
2056
2057 TvEvent::SignalInfoEvent ev;
2058 ev.mTrans_fmt = info.trans_fmt;
2059 ev.mFmt = info.fmt;
2060 ev.mStatus = info.status;
2061 ev.mReserved = info.reserved;
2062 sendTvEvent ( ev );
2063 LOGD ( "%s, Enable blackscreen for signal change in UnStableToUnSupport!", __FUNCTION__);
2064}
2065void CTv::onSigUnStableToNoSig()
2066{
2067 mTvAudio.SetAudioMuteForTv(CC_AUDIO_MUTE);
2068 mAv.DisableVideoWithBlueColor();
2069 //SetAudioMuteForTv(CC_AUDIO_MUTE);
2070 mTvin.Tvin_StopDecoder();
2071
2072 tvin_info_t info = mSigDetectThread.getCurSigInfo();
2073 TvEvent::SignalInfoEvent ev;
2074 ev.mTrans_fmt = info.trans_fmt;
2075 ev.mFmt = info.fmt;
2076 ev.mStatus = info.status;
2077 ev.mReserved = info.reserved;
2078 sendTvEvent ( ev );
2079 LOGD ( "%s, Enable bluescreen for signal change in UnStableToNoSig! status = %d", __FUNCTION__, ev.mStatus );
2080}
2081void CTv::onSigNullToNoSig()
2082{
2083 mTvAudio.SetAudioMuteForTv(CC_AUDIO_MUTE);
2084 mAv.DisableVideoWithBlueColor();
2085 //SetAudioMuteForTv(CC_AUDIO_MUTE);
2086 mTvin.Tvin_StopDecoder();
2087
2088 tvin_info_t info = mSigDetectThread.getCurSigInfo();
2089
2090
2091 TvEvent::SignalInfoEvent ev;
2092 ev.mTrans_fmt = info.trans_fmt;
2093 ev.mFmt = info.fmt;
2094 ev.mStatus = info.status;
2095 ev.mReserved = info.reserved;
2096 sendTvEvent ( ev );
2097 LOGD ( "%s, Enable bluescreen for signal change in NullToNoSig!", __FUNCTION__);
2098}
2099
2100void CTv::onSigNoSigToUnstable()
2101{
2102 mAv.DisableVideoWithBlueColor();
2103 LOGD("Enable bluescreen for signal change in NoSigToUnstable\n");
2104}
2105
2106void CTv::onSigStillStable()
2107{
2108 if ( m_sig_stable_nums == 20) {
2109 tvin_info_t info = mSigDetectThread.getCurSigInfo();
2110 TvEvent::SignalInfoEvent ev;
2111 ev.mTrans_fmt = info.trans_fmt;
2112 ev.mFmt = info.fmt;
2113 ev.mStatus = info.status;
2114 ev.mReserved = info.reserved;
2115 sendTvEvent ( ev );
2116 }
2117 if(m_sig_stable_nums == 2) {
2118 int startdec_status = mTvin.Tvin_StartDecoder ( mSigDetectThread.getCurSigInfo() );
2119 if ( startdec_status == 0 ) { //showboz codes from start decode fun
2120 const char *value;
2121 value = config_get_str ( "TV", "tvin.db.reg.en", "null" );
2122 if ( strcmp ( value, "enable" ) == 0 ) {
2123 usleep ( 20 * 1000 );
2124 Tvin_SetPLLValues ();
2125 usleep ( 20 * 1000 );
2126 SetCVD2Values ();
2127 }
2128 }
2129 }
2130 if ( m_sig_stable_nums == 25 ) {
2131 if(!(mTvAction & TV_ACTION_SCANNING))
2132 mTvAudio.SetAudioMuteForTv ( CC_AUDIO_UNMUTE );
2133 mAv.EnableVideoAuto();
2134 }
2135
2136 m_sig_stable_nums++;
2137}
2138void CTv::onSigStillUnstable()
2139{
2140}
2141void CTv::onSigStillNosig()
2142{
2143
2144}
2145void CTv::onSigStillNoSupport()
2146{
2147
2148 tvin_info_t info = mSigDetectThread.getCurSigInfo();
2149 TvEvent::SignalInfoEvent SigEv;
2150 SigEv.mTrans_fmt = info.trans_fmt;
2151 SigEv.mFmt = info.fmt;
2152 SigEv.mStatus = info.status;
2153 SigEv.mReserved = info.reserved;
2154 sendTvEvent ( SigEv );
2155 LOGD ( "%s, Unsupport signal", __FUNCTION__);
2156}
2157void CTv::onSigStillNull()
2158{
2159}
2160void CTv::onStableSigFmtChange()
2161{
2162}
2163void CTv::onStableTransFmtChange()
2164{
2165}
2166void CTv::onSigDetectEnter()
2167{
2168 struct timeval time;
2169 gettimeofday ( &time, NULL );
2170}
2171
2172void CTv::onLoop()
2173{
2174 if ( ( m_is_hdmi_sr_detect_start == true )
2175 && ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) ) {
2176 int sr = mTvin.get_hdmi_sampling_rate();
2177
2178 if ( ( sr > 0 ) && ( sr != m_hdmi_sampling_rate ) ) {
2179 if ( 0 == m_hdmi_sampling_rate ) {
2180 LOGD ( "%s, Init HDMI audio, sampling rate:%d", __FUNCTION__, sr );
2181 mTvAudio.AudioDataInit ( sr, false );
2182 audio_sr = sr;
2183 } else {
2184 LOGD ( "%s, Reset HDMI sampling rate to %d", __FUNCTION__, sr );
2185 mTvAudio.AudioChangeSampleRate ( sr );
2186 }
2187
2188 m_hdmi_sampling_rate = sr;
2189 }
2190 }
2191}
2192
2193void CTv::onSourceConnect(int source_type, int connect_status)
2194{
2195 TvEvent::SourceConnectEvent ev;
2196 ev.mSourceInput = source_type;
2197 ev.connectionState = connect_status;
2198 sendTvEvent(ev);
2199}
2200
2201int CTv::GetSourceConnectStatus(int source_input)
2202{
2203 return mSourceConnectDetectThread.GetSourceConnectStatus(source_input);
2204}
2205
2206tv_source_input_t CTv::GetCurrentSourceInputLock ( void )
2207{
2208 Mutex::Autolock _l ( mLock );
2209 return m_source_input;
2210}
2211
2212//dtv and tvin
2213tvin_info_t CTv::GetCurrentSignalInfo ( void )
2214{
2215 tvin_trans_fmt det_fmt = TVIN_TFMT_2D;
2216 tvin_sig_status_t signalState = TVIN_SIG_STATUS_NULL;
2217 tvin_info_t signal_info = mSigDetectThread.getCurSigInfo();
2218
2219 if ( (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_DTV ) ) {
2220 for ( int i = 0; i < 10; i++ ) {
2221 det_fmt = mTvin.TvinApi_Get3DDectMode();
2222 signal_info.status = TVIN_SIG_STATUS_STABLE;
2223
2224 if ( det_fmt != TVIN_TFMT_2D ) {
2225 signal_info.trans_fmt = det_fmt;
2226 break;
2227 }
2228 }
2229 }
2230 return signal_info;
2231}
2232
2233int CTv::Tv_Set3DMode ( VIDEO_3D_MODE_T mode )
2234{
2235 if (mode == VIDEO_3D_MODE_AUTO) {
2236 mTvin.VDIN_SetDI3DDetc (1);
2237 } else {
2238 mTvin.VDIN_SetDI3DDetc (0);
2239 }
2240
2241 mAv.set3DMode(mode, 0, 0);
2242 m_mode_3d = mode;
2243 SSMSave3DMode ( ( unsigned char ) mode );
2244 SetBypassModulesFor3D ( mode );
2245 return 0;
2246}
2247
2248VIDEO_3D_MODE_T CTv::Tv_Get3DMode ( void )
2249{
2250 return m_mode_3d;
2251}
2252
2253int CTv::Tv_Set3DLRSwith ( int on_off)
2254{
2255 LOGW ( "%s,Set3D LRSwith on_off %d ,status %d !!! ", __FUNCTION__, on_off);
2256 mAv.set3DMode(m_mode_3d, on_off, 0);
2257 SSMSave3DLRSwitch(on_off);
2258 return 0;
2259}
2260
2261int CTv::Tv_Get3DLRSwith ( void )
2262{
2263 unsigned char val = 0;
2264 SSMRead3DLRSwitch ( &val );
2265 return ( int ) val;
2266}
2267
2268int CTv::Tv_Set3DTo2DMode ( int mode)
2269{
2270 LOGW ( "%s,Set3D to 2D mode %d ,status %d !!! ", __FUNCTION__ , mode);
2271 mAv.set3DMode(m_mode_3d, 0, mode);
2272 SSMSave3DTO2D ( mode );
2273 return 0;
2274}
2275
2276int CTv::Tv_Get3DTo2DMode ( void )
2277{
2278 unsigned char val = 0;
2279 SSMRead3DTO2D ( &val );
2280 return val;
2281}
2282
2283int CTv::Tv_Set3DDepth ( int value )
2284{
2285 mTvin.Tvin_SetDepthOf2Dto3D( value );
2286 SSMSave3DDepth ( value );
2287 return 0;
2288}
2289
2290int CTv::GetSave3DDepth ( void )
2291{
2292 unsigned char val = 0;
2293 SSMRead3DDepth ( &val );
2294 return val;
2295}
2296
2297is_3d_type_t CTv::Check2Dor3D ( VIDEO_3D_MODE_T mode3d, tvin_trans_fmt_t trans_fmt )
2298{
2299 if ( mode3d == VIDEO_3D_MODE_DISABLE ) {
2300 return INDEX_2D;
2301 } else if ( mode3d == VIDEO_3D_MODE_AUTO ) {
2302 if ( trans_fmt == TVIN_TFMT_2D ) {
2303 return INDEX_2D;
2304 } else {
2305 return INDEX_3D;
2306 }
2307 } else {
2308 return INDEX_3D;
2309 }
2310}
2311
2312
2313int CTv::Tvin_SetPLLValues ()
2314{
2315 tvin_sig_fmt_t sig_fmt = mSigDetectThread.getCurSigInfo().fmt;
2316 tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceInput(m_source_input);
2317 am_regs_t regs;
2318
2319 if ( mVpp.getPqData()->PQ_GetPLLParams ( source_port, sig_fmt, &regs ) == 0 ) {
2320 LOGD ("%s,PQ_GetPLLParams(source_port[%d], sig_fmt[%d],&regs).\n", __FUNCTION__, source_port, sig_fmt );
2321
2322 if ( mTvin.TvinApi_LoadPLLValues ( regs ) < 0 ) {
2323 LOGE ( "%s, TvinApi_LoadPLLValues failed!\n", __FUNCTION__ );
2324 return -1;
2325 }
2326 } else {
2327 LOGE ( "%s, PQ_GetPLLParams failed!\n", __FUNCTION__ );
2328 return -1;
2329 }
2330
2331 return 0;
2332}
2333int CTv::SetCVD2Values ()
2334{
2335 tvin_sig_fmt_t sig_fmt = mSigDetectThread.getCurSigInfo().fmt;
2336 tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceInput(m_source_input);
2337 am_regs_t regs;
2338
2339 if (mVpp.getPqData()->PQ_GetCVD2Params ( source_port, sig_fmt, &regs ) == 0) {
2340 LOGD ( "%s, PQ_GetCVD2Params(source_port[%d], sig_fmt[%d],&regs).\n", __FUNCTION__,
2341 source_port, sig_fmt );
2342
2343 if ( mTvin.TvinApi_LoadCVD2Values ( regs ) < 0 ) {
2344 LOGE ( "%s, TvinApi_LoadCVD2Values failed!\n", __FUNCTION__);
2345 return -1;
2346 }
2347 } else {
2348 LOGE ( "%s, PQ_GetCVD2Params failed!\n", __FUNCTION__);
2349 return -1;
2350 }
2351
2352 return 0;
2353}
2354
2355int CTv::SetPreviewWindow ( tvin_window_pos_t pos )
2356{
2357 m_win_pos.x1 = pos.x1;
2358 m_win_pos.y1 = pos.y1;
2359 m_win_pos.x2 = pos.x2;
2360 m_win_pos.y2 = pos.y2;
2361 LOGD ( "%s, SetPreviewWindow x = %d y=%d", __FUNCTION__, pos.x2, pos.y2 );
2362
2363 tvin_window_pos_t def_pos;
2364 Vpp_GetDisplayResolutionInfo(&def_pos);
2365
2366 if (pos.x1 != 0 || pos.y1 != 0 || pos.x2 != def_pos.x2 || pos.y2 != def_pos.y2) {
2367 m_win_mode = PREVIEW_WONDOW;
2368 } else {
2369 m_win_mode = NORMAL_WONDOW;
2370 }
2371
2372 return mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2);;
2373}
2374
2375/*********************** Audio start **********************/
2376int CTv::SetAudioVolDigitLUTBuf ( tv_source_input_t source_input )
2377{
2378 if (source_input == SOURCE_TV) {
2379 mTvAudio.AudioSetVolumeDigitLUTBuf ( CC_LUT_SEL_TV, 1, 1, -1 );
2380 } else if (source_input == SOURCE_AV1 || source_input == SOURCE_AV2) {
2381 mTvAudio.AudioSetVolumeDigitLUTBuf ( CC_LUT_SEL_AV, 1, 1, -1 );
2382 } else if (source_input == SOURCE_YPBPR1 || source_input == SOURCE_YPBPR2) {
2383 mTvAudio.AudioSetVolumeDigitLUTBuf ( CC_LUT_SEL_COMP, 1, 1, -1 );
2384 } else if (source_input == SOURCE_VGA) {
2385 mTvAudio.AudioSetVolumeDigitLUTBuf ( CC_LUT_SEL_VGA, 1, 1, -1 );
2386 } else if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) {
2387 mTvAudio.AudioSetVolumeDigitLUTBuf ( CC_LUT_SEL_HDMI, 1, 1, -1 );
2388 } else if ( source_input == SOURCE_MPEG ) {
2389 mTvAudio.AudioSetVolumeDigitLUTBuf ( CC_LUT_SEL_MPEG, 1, 1, -1 );
2390 } else if ( source_input == SOURCE_DTV ) {
2391 mTvAudio.AudioSetVolumeDigitLUTBuf ( CC_LUT_SEL_MPEG, 1, 1, -1 );
2392 }
2393 return 0;
2394}
2395
2396void CTv::RefreshAudioMasterVolume ( tv_source_input_t source_input )
2397{
2398 if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) {
2399 if ( GetAudioDVISupportEnable() == 1 ) {
2400 if ( IsDVISignal() ) {
2401 SetAudioVolDigitLUTBuf ( SOURCE_MPEG );
2402 mTvAudio.SetAudioMasterVolume ( mTvAudio.GetAudioMasterVolume() );
2403 return;
2404 }
2405 }
2406 }
2407
2408 SetAudioVolDigitLUTBuf ( source_input );
2409 mTvAudio.SetAudioMasterVolume ( mTvAudio.GetAudioMasterVolume() );
2410}
2411
2412int CTv::Tv_SetAudioInSource (tv_source_input_t source_input)
2413{
2414 if (source_input == SOURCE_TV) {
2415 if (mTvin.Tvin_GetAudioInSourceType(source_input) == TV_AUDIO_IN_SOURCE_TYPE_ATV) {
2416 return mTvAudio.AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_ATV);
2417 } else {
2418 return mTvAudio.AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_LINEIN);
2419 }
2420 } else if (source_input == SOURCE_AV1 || source_input == SOURCE_AV2) {
2421 return mTvAudio.AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_LINEIN);
2422 } else if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) {
2423 return mTvAudio.AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_HDMI);
2424 } else if (source_input == SOURCE_YPBPR1 || source_input == SOURCE_YPBPR2 ||
2425 source_input == SOURCE_TYPE_VGA) {
2426 return mTvAudio.AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_LINEIN);
2427 }
2428
2429 return 0;
2430}
2431
2432int CTv::Tv_SetAudioSourceType (tv_source_input_t source_input)
2433{
2434 int audio_source = -1;
2435
2436 if (source_input == SOURCE_TV) {
2437 audio_source = AUDIO_ATV_SOURCE;
2438 } else if (source_input == SOURCE_AV1 || source_input == SOURCE_AV2) {
2439 audio_source = AUDIO_AV_SOURCE;
2440 } else if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) {
2441 audio_source = AUDIO_HDMI_SOURCE;
2442 } else if (source_input == SOURCE_YPBPR1 || source_input == SOURCE_YPBPR2 ||
2443 source_input == SOURCE_TYPE_VGA) {
2444 audio_source = AUDIO_AV_SOURCE;
2445 } else if (source_input == SOURCE_DTV) {
2446 audio_source = AUDIO_MPEG_SOURCE;
2447 } else {
2448 audio_source = AUDIO_MPEG_SOURCE;
2449 }
2450
2451 return mTvAudio.AudioSetAudioSourceType(audio_source);
2452}
2453void CTv::Tv_SetAudioOutputSwap_Type (tv_source_input_t source_input)
2454{
2455 const char *config_value;
2456 config_value = config_get_str("TV", "audio.output.swap.enable", "null");
2457 if ( strcmp ( config_value, "enable" ) == 0 ) {
2458 int sw_status = 0;
2459
2460 LOGD("%s, audio.output.swap.enable\n", __FUNCTION__);
2461
2462 switch(source_input) {
2463 case SOURCE_AV1:
2464 config_value = config_get_str("TV", "audio.output.swap.av1", "null");
2465 sw_status = atoi ( config_value );
2466 mTvAudio.SetOutput_Swap(sw_status);
2467 LOGD("%s, av1 %d\n", __FUNCTION__, sw_status);
2468 break;
2469 case SOURCE_AV2:
2470 config_value = config_get_str("TV", "audio.output.swap.av2", "null");
2471 sw_status = atoi ( config_value );
2472 mTvAudio.SetOutput_Swap(sw_status);
2473 LOGD("%s, av2 %d\n", __FUNCTION__, sw_status);
2474 break;
2475 case SOURCE_HDMI1:
2476 config_value = config_get_str("TV", "audio.output.swap.hdmi1", "null");
2477 sw_status = atoi ( config_value );
2478 mTvAudio.SetOutput_Swap(sw_status);
2479 LOGD("%s, hdmi1 %d\n", __FUNCTION__, sw_status);
2480 break;
2481 case SOURCE_HDMI2:
2482 config_value = config_get_str("TV", "audio.output.swap.hdmi2", "null");
2483 sw_status = atoi ( config_value );
2484 mTvAudio.SetOutput_Swap(sw_status);
2485 LOGD("%s, hdmi2 %d\n", __FUNCTION__, sw_status);
2486 break;
2487 case SOURCE_HDMI3:
2488 config_value = config_get_str("TV", "audio.output.swap.hdmi3", "null");
2489 sw_status = atoi ( config_value );
2490 mTvAudio.SetOutput_Swap(sw_status);
2491 LOGD("%s, hdmi3 %d\n", __FUNCTION__, sw_status);
2492 break;
2493 case SOURCE_TV:
2494 config_value = config_get_str("TV", "audio.output.swap.tv", "null");
2495 sw_status = atoi ( config_value );
2496 mTvAudio.SetOutput_Swap(sw_status);
2497 LOGD("%s, tv %d\n", __FUNCTION__, sw_status);
2498 break;
2499 case SOURCE_DTV:
2500 config_value = config_get_str("TV", "audio.output.swap.dtv", "null");
2501 sw_status = atoi ( config_value );
2502 mTvAudio.SetOutput_Swap(sw_status);
2503 LOGD("%s, dtv %d\n", __FUNCTION__, sw_status);
2504 break;
2505 case SOURCE_MPEG:
2506 config_value = config_get_str("TV", "audio.output.swap.mpeg", "null");
2507 sw_status = atoi ( config_value );
2508 mTvAudio.SetOutput_Swap(sw_status);
2509 LOGD("%s, mpeg %d\n", __FUNCTION__, sw_status);
2510 break;
2511 default:
2512 mTvAudio.SetOutput_Swap(sw_status);
2513 LOGD("%s, default %d\n", __FUNCTION__, sw_status);
2514 break;
2515 }
2516 }
2517
2518}
2519
2520/*********************** Audio end **********************/
2521
2522unsigned int CTv::Vpp_GetDisplayResolutionInfo(tvin_window_pos_t *win_pos)
2523{
2524 int display_resolution = mAv.getVideoDisplayResolution();
2525 unsigned int tmp_ret = 0;
2526
2527 switch(display_resolution) {
2528 case VPP_DISPLAY_RESOLUTION_1366X768:
2529 tmp_ret |= (CC_RESOLUTION_1366X768_W << 16);
2530 tmp_ret |= (CC_RESOLUTION_1366X768_H << 0);
2531 break;
2532 case VPP_DISPLAY_RESOLUTION_1920X1080:
2533 tmp_ret |= (CC_RESOLUTION_1920X1080_W << 16);
2534 tmp_ret |= (CC_RESOLUTION_1920X1080_H << 0);
2535 break;
2536 case VPP_DISPLAY_RESOLUTION_3840X2160:
2537 tmp_ret |= (CC_RESOLUTION_3840X2160_W << 16);
2538 tmp_ret |= (CC_RESOLUTION_3840X2160_H << 0);
2539 break;
2540 default:
2541 tmp_ret |= (CC_RESOLUTION_3840X2160_W << 16);
2542 tmp_ret |= (CC_RESOLUTION_3840X2160_H << 0);
2543 break;
2544 }
2545
2546 if (win_pos != NULL) {
2547 win_pos->x1 = 0;
2548 win_pos->y1 = 0;
2549 win_pos->x2 = ((tmp_ret >> 16) & 0xFFFF) - 1;
2550 win_pos->y2 = ((tmp_ret >> 0) & 0xFFFF) - 1;
2551 }
2552
2553 return 0;
2554}
2555
2556
2557int CTv::setBlackoutEnable(int enable)
2558{
2559 m_blackout_enable = enable;
2560 return SSMSaveBlackoutEnable(enable);
2561}
2562
2563int CTv::getSaveBlackoutEnable()
2564{
2565 int8_t enable;
2566 SSMReadBlackoutEnable(&enable);
2567 return enable;
2568}
2569void CTv::startAutoBackLight()
2570{
2571 mAutoBackLight.startAutoBacklight(CTvin::Tvin_SourceInputToSourceInputType(m_source_input));
2572}
2573
2574void CTv::stopAutoBackLight()
2575{
2576 mAutoBackLight.stopAutoBacklight();
2577}
2578
2579int CTv::getAutoBackLight_on_off()
2580{
2581 return mAutoBackLight.isAutoBacklightOn() ? 1 : 0;
2582}
2583/*********************** SSM start **********************/
2584int CTv::Tv_SSMRestoreDefaultSetting()
2585{
2586 SSMRestoreDeviceMarkValues();
2587 mTvAudio.AudioSSMRestoreDefaultSetting();
2588 mVpp.VPPSSMRestoreDefault();
2589 MiscSSMRestoreDefault();
2590 ReservedSSMRestoreDefault();
2591 SSMSaveCVBSStd ( 0 );
2592 SSMSaveLastSelectSourceInput ( SOURCE_TV );
2593 SSMSavePanelType ( 0 );
2594 //tvconfig default
2595 saveDTVProgramID ( -1 );
2596 saveATVProgramID ( -1 );
2597 return 0;
2598}
2599
2600int CTv::clearDbAllProgramInfoTable()
2601{
2602 return CTvDatabase::GetTvDb()->clearDbAllProgramInfoTable();
2603}
2604
2605int CTv::Tv_SSMFacRestoreDefaultSetting()
2606{
2607 mVpp.VPPSSMFacRestoreDefault();
2608 mTvAudio.AudioSSMRestoreDefaultSetting();
2609 MiscSSMFacRestoreDefault();
2610
2611 return 0;
2612}
2613/*********************** SSM End **********************/
2614//not in CTv, not use lock
2615void CTv::setSourceSwitchAndPlay()
2616{
2617 int progID = 0;
2618 LOGD ( "%s\n", __FUNCTION__ );
2619 static const int POWERON_SOURCE_TYPE_NONE = 0;//not play source
2620 static const int POWERON_SOURCE_TYPE_LAST = 1;//play last save source
2621 static const int POWERON_SOURCE_TYPE_SETTING = 2;//play ui set source
2622 int to_play_source = -1;
2623 int powerup_type = SSMReadPowerOnOffChannel();
2624 LOGD("read power on source type = %d", powerup_type);
2625 if(powerup_type == POWERON_SOURCE_TYPE_NONE) {
2626 return ;
2627 } else if(powerup_type == POWERON_SOURCE_TYPE_LAST) {
2628 to_play_source = SSMReadSourceInput();
2629 } else if(powerup_type == POWERON_SOURCE_TYPE_SETTING) {
2630 to_play_source = SSMReadLastSelectSourceInput();
2631 }
2632 SetSourceSwitchInput (( tv_source_input_t ) to_play_source );
2633 if ( to_play_source == SOURCE_TV ) {
2634 progID = getATVProgramID();
2635 } else if ( to_play_source == SOURCE_DTV ) {
2636 progID = getDTVProgramID();
2637 }
2638 playProgramLock(progID);
2639 return;
2640}
2641
2642int CTv::startCC(int country, int src, int channel, int service)
2643{
2644 //turn_on_cc = true;
2645 return mTvSub.sub_start_atsc_cc((enum cc_param_country)country, (enum cc_param_source_type)src, channel, (enum cc_param_caption_type)service);
2646}
2647
2648int CTv::stopCC()
2649{
2650 //because cc,vchip data both come from vbi thread , here judge cc, vchip is whether both turn off
2651 /*turn_on_cc = false;
2652 if(config_get_int("TV","tv.vchip.enable", 0))
2653 {
2654 return 0; //at ATV if vchip is on, turn off CC, just set flag not display CC, but vchip still running
2655 }*/
2656 return mTvSub.sub_stop_atsc_cc();
2657}
2658
2659void CTv::printDebugInfo()
2660{
2661 print_version_info();
2662 LOGD("%s, TvAction = %x", __FUNCTION__, mTvAction);
2663 LOGD("%s, TvRunStatus = %d", __FUNCTION__, mTvStatus);
2664 LOGD("%s, TvCurSourceInput = %d", __FUNCTION__, m_source_input);
2665 LOGD("%s, TvLastSourceInput = %d", __FUNCTION__, m_last_source_input);
2666}
2667//==============vchip end================================
2668//----------------DVR API============================
2669void CTv::SetRecordFileName ( char *name )
2670{
2671 char tmp[256];
2672 strcpy ( tmp, name );
2673 mTvRec.SetRecordFileName ( tmp );
2674}
2675void CTv::StartToRecord()
2676{
2677 int progID = getDTVProgramID();
2678 mTvRec.StartRecord ( progID );
2679}
2680void CTv::StopRecording()
2681{
2682 mTvRec.StopRecord();
2683}
2684void CTv::SetRecCurTsOrCurProgram ( int sel )
2685{
2686 mTvRec.SetRecCurTsOrCurProgram ( sel );
2687}
2688
2689int CTv::GetDisplayResolutionConfig()
2690{
2691 return mAv.getVideoDisplayResolution();
2692}
2693
2694int CTv::GetDisplayResolutionInfo()
2695{
2696 return Vpp_GetDisplayResolutionInfo(NULL);
2697}
2698
2699void CTv::onHDMIRxCECMessage(int msg_len, unsigned char msg_buf[])
2700{
2701 int i = 0;
2702 TvEvent::HDMIRxCECEvent ev;
2703 ev.mDataCount = msg_len;
2704 for(i = 0; i < msg_len; i++) {
2705 ev.mDataBuf[i] = msg_buf[i];
2706 }
2707 sendTvEvent(ev);
2708}
2709
2710int CTv::SendHDMIRxCECCustomMessage(unsigned char data_buf[])
2711{
2712 tv_source_input_t source_input = m_source_input;
2713
2714 return mHDMIRxCEC.SendCustomMessage(source_input, data_buf);
2715}
2716
2717int CTv::SendHDMIRxCECCustomMessageAndWaitReply(unsigned char data_buf[], unsigned char reply_buf[], int WaitCmd, int timeout)
2718{
2719 tv_source_input_t source_input = m_source_input;
2720
2721 return mHDMIRxCEC.SendCustomMessageAndWaitReply(source_input, data_buf, reply_buf, WaitCmd, timeout);
2722}
2723
2724int CTv::SendHDMIRxCECBoradcastStandbyMessage(void)
2725{
2726 tv_source_input_t source_input = m_source_input;
2727
2728 return mHDMIRxCEC.SendBoradcastStandbyMessage(source_input);
2729}
2730
2731int CTv::SendHDMIRxCECGiveCECVersionMessage(tv_source_input_t source_input, unsigned char data_buf[])
2732{
2733 if (mHDMIRxCEC.processRefreshSrcDevice(source_input) == 0) {
2734 return mHDMIRxCEC.SendGiveCECVersionMessage(source_input, data_buf);
2735 }
2736
2737 return -1;
2738}
2739
2740int CTv::SendHDMIRxCECGiveDeviceVendorIDMessage(tv_source_input_t source_input, unsigned char data_buf[])
2741{
2742 if (mHDMIRxCEC.processRefreshSrcDevice(source_input) == 0) {
2743 return mHDMIRxCEC.SendGiveDeviceVendorIDMessage(source_input, data_buf);
2744 }
2745
2746 return -1;
2747}
2748
2749int CTv::SendHDMIRxCECGiveOSDNameMessage(tv_source_input_t source_input, unsigned char data_buf[])
2750{
2751 if (mHDMIRxCEC.processRefreshSrcDevice(source_input) == 0) {
2752 return mHDMIRxCEC.SendGiveOSDNameMessage(source_input, data_buf);
2753 }
2754
2755 return -1;
2756}
2757
2758int CTv::GetHdmiHdcpKeyKsvInfo(int data_buf[])
2759{
2760 return mTvin.get_hdmi_ksv_info(m_source_input, data_buf);
2761}
2762
2763void CTv::onUpgradeStatus(int state, int param)
2764{
2765 TvEvent::UpgradeFBCEvent ev;
2766 ev.mState = state;
2767 ev.param = param;
2768 sendTvEvent(ev);
2769}
2770
2771int CTv::StartUpgradeFBC(char *file_name, int mode, int upgrade_blk_size)
2772{
2773 if (mpUpgradeFBC != NULL) {
2774 mpUpgradeFBC->SetUpgradeFileName(file_name);
2775 mpUpgradeFBC->SetUpgradeMode(mode);
2776 mpUpgradeFBC->SetUpgradeBlockSize(upgrade_blk_size);
2777 mpUpgradeFBC->start();
2778 return 0;
2779 }
2780
2781 return -1;
2782}
2783
2784void CTv::onSerialCommunication(int dev_id, int rd_len, unsigned char data_buf[])
2785{
2786 int i = 0;
2787 TvEvent::SerialCommunicationEvent ev;
2788 ev.mDevId = dev_id;
2789 ev.mDataCount = rd_len;
2790 for(i = 0; i < rd_len; i++) {
2791 ev.mDataBuf[i] = data_buf[i];
2792 }
2793 sendTvEvent(ev);
2794}
2795
2796void CTv::onThermalDetect(int state)
2797{
2798 const char *value;
2799 const char *value_normal;
2800 const char *value_cold;
2801 int threshold = 0, val = 0;
2802 static int pre_val = -1;
2803
2804 value = config_get_str ( "TV", "tvin.thermal.threshold.enable", "null" );
2805
2806 if ( strcmp ( value, "enable" ) == 0 ) {
2807
2808 value = config_get_str ( "TV", "tvin.thermal.threshold.value", "null" );
2809
2810 threshold = atoi(value);
2811 LOGD ( "%s, threshold value: %d\n", __FUNCTION__, threshold);
2812
2813 if(state > threshold) {
2814 value_normal = config_get_str ( "TV", "tvin.thermal.fbc.normal.value", "null" );
2815 val = atoi(value_normal);
2816 if(val == 0) {
2817 val = 0x4210000; //normal default
2818 }
2819 LOGD ( "%s, current temp: %d set 1\n", __FUNCTION__, state);
2820 } else {
2821 value_cold = config_get_str ( "TV", "tvin.thermal.fbc.cold.value", "null" );
2822 val = atoi(value_cold);
2823 if(val == 0) {
2824 val = 0x8210000; //cold default
2825 }
2826 LOGD ( "%s, current temp: 0x%x set 0\n", __FUNCTION__, state);
2827 }
2828
2829 if(pre_val == val) {
2830 LOGD ( "%s, pre_val == val : 0x%x,bypass\n", __FUNCTION__, val);
2831 } else {
2832 pre_val = val;
2833 Tv_FactorySet_FBC_Thermal_State(val);
2834 LOGD ( "%s, pre_val :0x%x,bypass\n", __FUNCTION__, pre_val);
2835 }
2836 } else {
2837 LOGD ( "%s, tvin.thermal.threshold.enable == disable\n", __FUNCTION__);
2838 }
2839}
2840
2841int CTv::SetSerialSwitch(int dev_id, int switch_val)
2842{
2843 int tmp_ret = 0;
2844
2845 if (dev_id == SERIAL_A) {
2846 if (switch_val == 0) {
2847 tmp_ret |= mSerialA.stop();
2848 tmp_ret |= mSerialA.CloseModule();
2849
2850 tmp_ret |= system("start console");
2851 } else {
2852 tmp_ret |= system("stop console");
2853
2854 mSerialA.OpenModule(dev_id);
2855 tmp_ret |= mSerialA.start();
2856 }
2857 } else if (dev_id == SERIAL_B) {
2858 if (switch_val == 0) {
2859 tmp_ret |= mSerialB.stop();
2860 tmp_ret |= mSerialB.CloseModule();
2861 } else {
2862 mSerialB.OpenModule(dev_id);
2863 tmp_ret = mSerialB.start();
2864 }
2865 } else if (dev_id == SERIAL_C) {
2866 if (switch_val == 0) {
2867 tmp_ret |= mSerialC.stop();
2868 tmp_ret |= mSerialC.CloseModule();
2869 } else {
2870 mSerialC.OpenModule(dev_id);
2871 tmp_ret = mSerialC.start();
2872 }
2873 }
2874
2875 return tmp_ret;
2876}
2877
2878int CTv::SendSerialData(int dev_id, int data_len, unsigned char data_buf[])
2879{
2880 int tmp_ret = 0;
2881
2882 if (dev_id == SERIAL_A) {
2883 tmp_ret = mSerialA.sendData(data_len, data_buf);
2884 } else if (dev_id == SERIAL_B) {
2885 tmp_ret = mSerialB.sendData(data_len, data_buf);
2886 } else if (dev_id == SERIAL_C) {
2887 tmp_ret = mSerialC.sendData(data_len, data_buf);
2888 }
2889
2890 return tmp_ret;
2891}
2892
2893int CTv::ChannelExport(const char *destPath)
2894{
2895 //DIR *dirptr = NULL;
2896 //dirptr = opendir("/storage/external_storage/sda1/");
2897 //if(NULL == dirptr) {
2898 // LOGD("%s, please insert the udisk !",__FUNCTION__);
2899 // return -2;
2900 // } else {
2901 char tmp[256];
2902 FILE *fp = NULL;
2903 if(destPath == NULL) {
2904 destPath = "/storage/external_storage/sda1/";
2905 }
2906
2907 //LOGD("%s, udisk exist !",__FUNCTION__);
2908 sprintf(tmp, "cp /param/dtv.db %s", destPath);
2909 if(system(tmp) >= 0) {
2910 LOGD("%s, copy dtv.db from /param to udisk success !", __FUNCTION__);
2911 system("sync");
2912 fp = fopen(destPath, "r");
2913 if (fp == NULL) {
2914 return -1;
2915 } else {
2916 fclose(fp);
2917 fp = NULL;
2918 return 0;
2919 }
2920 } else {
2921 return -1;
2922 }
2923 //}
2924}
2925
2926int CTv::ChannelImport(const char *srcPath)
2927{
2928 if(srcPath == NULL) {
2929 srcPath = "/storage/external_storage/sda1/dvb.db";
2930 }
2931
2932 if(Tv_Utils_IsFileExist(srcPath) == 0) {
2933 char tmp[256];
2934 LOGD("%s, file exist !" , srcPath);
2935 CTvDatabase::GetTvDb()->UnInitTvDb();
2936 sprintf(tmp, "rm /param/dtv.db");
2937 if(system(tmp) >= 0) {
2938 LOGD("%s, rm /param/dtv.db success !", __FUNCTION__);
2939 memset(tmp, 0, sizeof(tmp));
2940 sprintf(tmp, "cp %s /param/dtv.db", srcPath);
2941 if(system(tmp) >= 0) {
2942 LOGD("%s, copy to /param/dtv.db success !", srcPath);
2943 system("sync");
2944 CTvDatabase::GetTvDb()->InitTvDb(TV_DB_PATH);
2945 return 0;
2946 } else {
2947 LOGD("%s, copy dtv.db from udisk to /param failed !", __FUNCTION__);
2948 return -1;
2949 }
2950 } else {
2951 LOGD("%s, rm /param/dtv.db failed !", __FUNCTION__);
2952 return -2;
2953 }
2954 } else {
2955 LOGD("%s, dtv.db file does not exist in the udisk!" , srcPath);
2956 return -2;
2957 }
2958
2959}
2960
2961int CTv::Tv_GetProjectInfo(project_info_t *ptrInfo)
2962{
2963 return GetProjectInfo(ptrInfo);
2964}
2965
2966int CTv::Tv_GetPlatformType()
2967{
2968 return GetPlatformHaveFBCFlag();
2969}
2970
2971int CTv::Tv_SetDDDRCMode(tv_source_input_t source_input)
2972{
2973 if (source_input == SOURCE_DTV) {
2974 if (GetPlatformHaveDDFlag() == 1) {
2975 Tv_Utils_SetFileAttrStr("/sys/class/audiodsp/ac3_drc_control", "drcmode 3");
2976 }
2977 } else {
2978 if (GetPlatformHaveDDFlag() == 1) {
2979 Tv_Utils_SetFileAttrStr("/sys/class/audiodsp/ac3_drc_control", "drcmode 2");
2980 }
2981 }
2982
2983 return 0;
2984}
2985
2986//PQ
2987int CTv::Tv_SetBrightness ( int brightness, tv_source_input_type_t source_type, int is_save )
2988{
2989 return mVpp.Tv_SetBrightness(brightness, (tv_source_input_type_t)source_type, mSigDetectThread.getCurSigInfo().fmt, mSigDetectThread.getCurSigInfo().trans_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), is_save);
2990}
2991
2992int CTv::Tv_GetBrightness ( tv_source_input_type_t source_type )
2993{
2994 return mVpp.Tv_GetBrightness((tv_source_input_type_t)source_type);
2995}
2996
2997int CTv::Tv_SetContrast ( int contrast, tv_source_input_type_t source_type, int is_save )
2998{
2999 return mVpp.Tv_SetContrast(contrast, (tv_source_input_type_t)source_type, mSigDetectThread.getCurSigInfo().fmt, mSigDetectThread.getCurSigInfo().trans_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), is_save);
3000}
3001
3002int CTv::Tv_GetContrast ( tv_source_input_type_t source_type )
3003{
3004 return mVpp.Tv_GetContrast((tv_source_input_type_t)source_type);
3005}
3006
3007int CTv::Tv_SetSaturation ( int satuation, tv_source_input_type_t source_type, tvin_sig_fmt_t fmt, int is_save )
3008{
3009 return mVpp.Tv_SetSaturation(satuation, (tv_source_input_type_t)source_type, (tvin_sig_fmt_t)fmt, mSigDetectThread.getCurSigInfo().trans_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), is_save);
3010}
3011
3012int CTv::Tv_GetSaturation ( tv_source_input_type_t source_type )
3013{
3014 return mVpp.Tv_GetSaturation((tv_source_input_type_t)source_type);
3015}
3016
3017int CTv::Tv_SetHue ( int hue, tv_source_input_type_t source_type, tvin_sig_fmt_t fmt, int is_save )
3018{
3019 return mVpp.Tv_SetHue(hue, (tv_source_input_type_t)source_type, (tvin_sig_fmt_t)fmt, mSigDetectThread.getCurSigInfo().trans_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), is_save);
3020}
3021
3022int CTv::Tv_GetHue ( tv_source_input_type_t source_type )
3023{
3024 return mVpp.Tv_GetHue((tv_source_input_type_t)source_type);
3025}
3026
3027int CTv::Tv_SetPQMode ( vpp_picture_mode_t mode, tv_source_input_type_t source_type, int is_save )
3028{
3029 return mVpp.Tv_SetPQMode((vpp_picture_mode_t)mode, (tv_source_input_type_t)source_type, mSigDetectThread.getCurSigInfo().fmt, mSigDetectThread.getCurSigInfo().trans_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), is_save);
3030}
3031
3032vpp_picture_mode_t CTv::Tv_GetPQMode ( tv_source_input_type_t source_type )
3033{
3034 return mVpp.Tv_GetPQMode((tv_source_input_type_t)source_type);
3035}
3036
3037int CTv::Tv_SetSharpness ( int value, tv_source_input_type_t source_type, int en, int is_save )
3038{
3039 return mVpp.Tv_SetSharpness(value, (tv_source_input_type_t)source_type, en, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().fmt, mSigDetectThread.getCurSigInfo().trans_fmt, is_save);
3040}
3041
3042int CTv::Tv_GetSharpness ( tv_source_input_type_t source_type )
3043{
3044 return mVpp.Tv_GetSharpness((tv_source_input_type_t)source_type);
3045}
3046
3047int CTv::Tv_SaveSharpness ( int value, tv_source_input_type_t source_type, int en )
3048{
3049 if ( en == 1 ) {
3050 return SSMSaveSharpness( (tv_source_input_type_t)source_type, value );
3051 } else {
3052 return 0;
3053 }
3054}
3055
3056int CTv::Tv_SetBacklight ( int value, tv_source_input_type_t source_type, int is_save )
3057{
3058 return mVpp.Tv_SetBacklight(value, (tv_source_input_type_t)source_type, is_save);
3059}
3060
3061int CTv::Tv_GetBacklight ( tv_source_input_type_t source_type )
3062{
3063 return mVpp.Tv_GetBacklight((tv_source_input_type_t)source_type);
3064}
3065
3066int CTv::Tv_SetColorTemperature ( vpp_color_temperature_mode_t mode, tv_source_input_type_t source_type, int is_save )
3067{
3068 return mVpp.Tv_SetColorTemperature((vpp_color_temperature_mode_t)mode, (tv_source_input_type_t)source_type, is_save);
3069}
3070
3071vpp_color_temperature_mode_t CTv::Tv_GetColorTemperature ( tv_source_input_type_t source_type )
3072{
3073 return mVpp.Tv_GetColorTemperature((tv_source_input_type_t)source_type);
3074}
3075
3076int CTv::Tv_SaveColorTemp ( vpp_color_temperature_mode_t mode, tv_source_input_type_t source_type )
3077{
3078 return mVpp.Tv_SaveColorTemp((vpp_color_temperature_mode_t)mode, (tv_source_input_type_t)source_type);
3079}
3080
3081int CTv::Tv_SetDisplayMode ( vpp_display_mode_t mode, tv_source_input_type_t source_type, tvin_sig_fmt_t fmt, int is_save )
3082{
3083 int ret = Vpp_SetDisplayMode((vpp_display_mode_t)mode, (tv_source_input_type_t)source_type, (tvin_sig_fmt_t)fmt);
3084 if(ret == 0) {
3085 if(is_save == 1) {
3086 ret = ret | SSMSaveDisplayMode ( source_type, (int)mode );
3087 }
3088 }
3089 return ret;
3090}
3091
3092int CTv::Vpp_SetDisplayMode ( vpp_display_mode_t display_mode, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt )
3093{
3094 LOGD("%s, display_mode = %d, source_type = %d. \n", __FUNCTION__, display_mode, source_type);
3095
3096 tvin_cutwin_t cutwin = mVpp.Tv_GetOverscan ( source_type, sig_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt);
3097 int video_screen_mode = CAv::VIDEO_WIDEOPTION_16_9;
3098 tvin_window_pos_t win_pos;
3099 int display_resolution = Vpp_GetDisplayResolutionInfo(&win_pos);
3100
3101
3102 if ( source_type == SOURCE_TYPE_HDMI ) {
3103 if ( sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_60HZ
3104 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080I_60HZ
3105 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_50HZ
3106 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080I_50HZ_A
3107 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080I_50HZ_B
3108 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_24HZ
3109 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_25HZ
3110 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_30HZ
3111 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080I_100HZ
3112 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080I_120HZ
3113 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_100HZ
3114 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_120HZ
3115 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080I_50HZ_FRAME_PACKING
3116 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_24HZ_FRAME_PACKING
3117 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_30HZ_FRAME_PACKING
3118 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080I_60HZ_ALTERNATIVE
3119 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080I_50HZ_ALTERNATIVE
3120 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_24HZ_ALTERNATIVE
3121 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_30HZ_ALTERNATIVE
3122 || sig_fmt == TVIN_SIG_FMT_HDMI_3840_2160_00HZ
3123 || sig_fmt == TVIN_SIG_FMT_HDMI_4096_2160_00HZ
3124
3125 ) {
3126 if ( display_mode == VPP_DISPLAY_MODE_NOSCALEUP ) {
3127 cutwin.vs = 0;
3128 cutwin.hs = 1;
3129 cutwin.ve = 0;
3130 cutwin.he = 1;
3131 }
3132 }
3133 }
3134
3135 switch ( display_mode ) {
3136 case VPP_DISPLAY_MODE_169:
3137 video_screen_mode = CAv::VIDEO_WIDEOPTION_16_9;
3138 break;
3139 case VPP_DISPLAY_MODE_MODE43:
3140 video_screen_mode = CAv::VIDEO_WIDEOPTION_4_3;
3141 break;
3142 case VPP_DISPLAY_MODE_NORMAL:
3143 video_screen_mode = CAv::VIDEO_WIDEOPTION_NORMAL;
3144 break;
3145 case VPP_DISPLAY_MODE_FULL:
3146 break;
3147 case VPP_DISPLAY_MODE_NOSCALEUP: {
3148 if ( source_type == SOURCE_TYPE_HDMI ) {
3149 int retValue = GetFileAttrIntValue ( "/sys/module/tvin_hdmirx/parameters/cur_colorspace" );
3150 switch ( retValue ) {
3151 case RGB_FORMAT:
3152 mVpp.Tv_SetColorSpaceMode ( VPP_COLOR_SPACE_RGB );
3153 cutwin.vs = 0;
3154 cutwin.hs = 0;
3155 cutwin.ve = 0;
3156 cutwin.he = 0;
3157 break;
3158
3159 default:
3160 mVpp.Tv_SetColorSpaceMode ( VPP_COLOR_SPACE_YUV );
3161 break;
3162 }
3163 } else {
3164 video_screen_mode = CAv::VIDEO_WIDEOPTION_NORMAL_NOSCALEUP;
3165 }
3166 break;
3167 }
3168 case VPP_DISPLAY_MODE_FULL_REAL:
3169 video_screen_mode = CAv::VIDEO_WIDEOPTION_16_9; //added for N360 by haifeng.liu
3170 break;
3171 case VPP_DISPLAY_MODE_PERSON:
3172 if ( display_resolution == VPP_DISPLAY_RESOLUTION_1366X768 ) {
3173 win_pos.y1 = -45;
3174 win_pos.y2 = win_pos.y2 - win_pos.y1;
3175 } else {
3176 win_pos.y1 = -65;
3177 win_pos.y2 = win_pos.y2 - win_pos.y1;
3178 }
3179 video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH;
3180 break;
3181 case VPP_DISPLAY_MODE_MOVIE:
3182 if ( display_resolution == VPP_DISPLAY_RESOLUTION_1366X768 ) {
3183 win_pos.y1 = -61;
3184 win_pos.y2 = win_pos.y2 - win_pos.y1;
3185 } else {
3186 win_pos.y1 = -86;
3187 win_pos.y2 = win_pos.y2 - win_pos.y1;
3188 }
3189 video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH;
3190 break;
3191 case VPP_DISPLAY_MODE_CAPTION:
3192 if (display_resolution == VPP_DISPLAY_RESOLUTION_1366X768 ) {
3193 win_pos.y1 = -61;
3194 win_pos.y2 = win_pos.y2 + 2;
3195 } else {
3196 win_pos.y1 = -86;
3197 win_pos.y2 = win_pos.y2 + 4;
3198 }
3199 video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH;
3200 break;
3201 case VPP_DISPLAY_MODE_ZOOM:
3202 if (display_resolution == VPP_DISPLAY_RESOLUTION_1366X768 ) {
3203 win_pos.y1 = -128;
3204 win_pos.y2 = win_pos.y2 - win_pos.y1;
3205 } else {
3206 win_pos.y1 = -180;
3207 win_pos.y2 = win_pos.y2 - win_pos.y1;
3208 }
3209 video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH;
3210 break;
3211 default:
3212 break;
3213 }
3214
3215 if ( display_mode == VPP_DISPLAY_MODE_FULL ) {
3216 if ( source_type == SOURCE_TYPE_HDMI ) {
3217 if ( sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_60HZ
3218 //|| sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080I_60HZ
3219 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_50HZ
3220 //|| sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080I_50HZ_A
3221 //|| sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080I_50HZ_B
3222 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_24HZ
3223 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_25HZ
3224 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_30HZ
3225 //|| sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080I_100HZ
3226 //|| sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080I_120HZ
3227 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_100HZ
3228 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_120HZ
3229 //|| sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080I_50HZ_FRAME_PACKING
3230 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_24HZ_FRAME_PACKING
3231 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_30HZ_FRAME_PACKING
3232 //|| sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080I_60HZ_ALTERNATIVE
3233 //|| sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080I_50HZ_ALTERNATIVE
3234 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_24HZ_ALTERNATIVE
3235 || sig_fmt == TVIN_SIG_FMT_HDMI_1920X1080P_30HZ_ALTERNATIVE
3236 || sig_fmt == TVIN_SIG_FMT_HDMI_3840_2160_00HZ
3237 || sig_fmt == TVIN_SIG_FMT_HDMI_4096_2160_00HZ ) {
3238 const char *config_value = config_get_str ( "TV", "vpp.hdmi.nonlinear.scaling", "null" );
3239 if ( strcmp ( config_value, "enable" ) == 0 ) {
3240 video_screen_mode = CAv::VIDEO_WIDEOPTION_NONLINEAR;
3241 mVpp.VPP_SetNonLinearFactor ( 20 );
3242 }
3243 } else {
3244 video_screen_mode = CAv::VIDEO_WIDEOPTION_NONLINEAR;
3245 mVpp.VPP_SetNonLinearFactor ( 20 );
3246 }
3247 cutwin.vs = 0;
3248 cutwin.hs = 1;
3249 cutwin.ve = 0;
3250 cutwin.he = 1;
3251 }
3252 }
3253
3254 if ( m_mode_3d == VIDEO_3D_MODE_DISABLE ) {
3255 if(display_mode == VPP_DISPLAY_MODE_FULL_REAL && source_type == SOURCE_TYPE_HDMI) {
3256 //added for N360 by haifeng.liu
3257 cutwin.vs = 0;
3258 cutwin.hs = 0;
3259 cutwin.ve = 0;
3260 cutwin.he = 0;
3261 }
3262 } else {
3263 cutwin.vs = 0;
3264 cutwin.hs = 0;
3265 cutwin.ve = 0;
3266 cutwin.he = 0;
3267 video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH;
3268 }
3269
3270 mAv.setVideoAxis ( win_pos.x1, win_pos.y1, win_pos.x2, win_pos.y2 );
3271 mAv.setVideoScreenMode(video_screen_mode);
3272 mVpp.VPP_SetVideoCrop(cutwin.vs, cutwin.hs, cutwin.ve, cutwin.he);
3273 return 0;
3274}
3275
3276vpp_display_mode_t CTv::Tv_GetDisplayMode ( tv_source_input_type_t source_type )
3277{
3278 return mVpp.Tv_GetDisplayMode((tv_source_input_type_t)source_type);
3279}
3280
3281int CTv::Tv_SaveDisplayMode ( vpp_display_mode_t mode, tv_source_input_type_t source_type )
3282{
3283 return SSMSaveDisplayMode ( source_type, (int)mode );
3284}
3285
3286int CTv::Tv_SetNoiseReductionMode ( vpp_noise_reduction_mode_t mode, tv_source_input_type_t source_type, int is_save )
3287{
3288 return mVpp.Tv_SetNoiseReductionMode((vpp_noise_reduction_mode_t)mode, (tv_source_input_type_t)source_type, mSigDetectThread.getCurSigInfo().fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt, is_save);
3289}
3290
3291vpp_noise_reduction_mode_t CTv::Tv_GetNoiseReductionMode ( tv_source_input_type_t source_type )
3292{
3293 return mVpp.Tv_GetNoiseReductionMode((tv_source_input_type_t)source_type);
3294}
3295
3296int CTv::Tv_SaveNoiseReductionMode ( vpp_noise_reduction_mode_t mode, tv_source_input_type_t source_type )
3297{
3298 return mVpp.Tv_SaveNoiseReductionMode((vpp_noise_reduction_mode_t)mode, (tv_source_input_type_t)source_type);
3299}
3300
3301int CTv::Tv_SetRGBOGO_PostOffset(int type, int offset)
3302{
3303 return mVpp.Tv_SetRGBOGO_PostOffset(type, offset);
3304}
3305
3306int CTv::Tv_SetRGBOGO_Gain(int type, int mode)
3307{
3308 return mVpp.Tv_SetRGBOGO_Gain(type, mode);
3309}
3310
3311int CTv::Tv_GetRGBOGO_PostOffset ( int type )
3312{
3313 return mVpp.Tv_GetRGBOGO_PostOffset(type);
3314}
3315
3316int CTv::Tv_GetRGBOGO_Gain ( int type )
3317{
3318 return mVpp.Tv_GetRGBOGO_Gain(type);
3319}
3320
3321int CTv::Tv_FactorySetPQMode_Brightness ( int source_type, int pq_mode, int brightness )
3322{
3323 return mVpp.Tv_FactorySetPQMode_Brightness(source_type, pq_mode, brightness);
3324}
3325
3326int CTv::Tv_FactoryGetPQMode_Brightness ( int source_type, int pq_mode )
3327{
3328 return mVpp.Tv_FactoryGetPQMode_Brightness(source_type, pq_mode);
3329}
3330
3331int CTv::Tv_FactorySetPQMode_Contrast ( int source_type, int pq_mode, int contrast )
3332{
3333 return mVpp.Tv_FactorySetPQMode_Contrast(source_type, pq_mode, contrast);
3334}
3335
3336int CTv::Tv_FactoryGetPQMode_Contrast ( int source_type, int pq_mode )
3337{
3338 return mVpp.Tv_FactoryGetPQMode_Contrast(source_type, pq_mode);
3339}
3340
3341int CTv::Tv_FactorySetPQMode_Saturation ( int source_type, int pq_mode, int saturation )
3342{
3343 return mVpp.Tv_FactorySetPQMode_Saturation(source_type, pq_mode, saturation);
3344}
3345
3346int CTv::Tv_FactoryGetPQMode_Saturation ( int source_type, int pq_mode )
3347{
3348 return mVpp.Tv_FactoryGetPQMode_Saturation(source_type, pq_mode);
3349}
3350
3351int CTv::Tv_FactorySetPQMode_Hue ( int source_type, int pq_mode, int hue )
3352{
3353 return mVpp.Tv_FactorySetPQMode_Hue(source_type, pq_mode, hue);
3354}
3355
3356int CTv::Tv_FactoryGetPQMode_Hue ( int source_type, int pq_mode )
3357{
3358 return mVpp.Tv_FactoryGetPQMode_Hue(source_type, pq_mode);
3359}
3360
3361int CTv::Tv_FactorySetPQMode_Sharpness ( int source_type, int pq_mode, int sharpness )
3362{
3363 return mVpp.Tv_FactorySetPQMode_Sharpness(source_type, pq_mode, sharpness);
3364}
3365
3366int CTv::Tv_FactoryGetPQMode_Sharpness ( int source_type, int pq_mode )
3367{
3368 return mVpp.Tv_FactoryGetPQMode_Sharpness(source_type, pq_mode);
3369}
3370
3371int CTv::Tv_FactorySetColorTemp_Rgain ( int source_type, int colortemp_mode, int rgain )
3372{
3373 return mVpp.Tv_FactorySetColorTemp_Rgain(source_type, colortemp_mode, rgain);
3374}
3375
3376int CTv::Tv_FactorySaveColorTemp_Rgain ( int source_type, int colortemp_mode, int rgain )
3377{
3378 return mVpp.Tv_FactorySaveColorTemp_Rgain(source_type, colortemp_mode, rgain);
3379}
3380
3381int CTv::Tv_FactoryGetColorTemp_Rgain ( int source_type, int colortemp_mode )
3382{
3383 return mVpp.Tv_FactoryGetColorTemp_Rgain(source_type, colortemp_mode);
3384}
3385
3386int CTv::Tv_FactorySetColorTemp_Ggain ( int source_type, int colortemp_mode, int ggain )
3387{
3388 return mVpp.Tv_FactorySetColorTemp_Ggain(source_type, colortemp_mode, ggain);
3389}
3390
3391int CTv::Tv_FactorySaveColorTemp_Ggain ( int source_type, int colortemp_mode, int ggain )
3392{
3393 return mVpp.Tv_FactorySaveColorTemp_Ggain(source_type, colortemp_mode, ggain);
3394}
3395
3396int CTv::Tv_FactoryGetColorTemp_Ggain ( int source_type, int colortemp_mode )
3397{
3398 return mVpp.Tv_FactoryGetColorTemp_Ggain(source_type, colortemp_mode);
3399}
3400
3401int CTv::Tv_FactorySetColorTemp_Bgain ( int source_type, int colortemp_mode, int bgain )
3402{
3403 return mVpp.Tv_FactorySetColorTemp_Bgain(source_type, colortemp_mode, bgain);
3404}
3405
3406int CTv::Tv_FactorySaveColorTemp_Bgain ( int source_type, int colortemp_mode, int bgain )
3407{
3408 return mVpp.Tv_FactorySaveColorTemp_Bgain(source_type, colortemp_mode, bgain);
3409}
3410
3411int CTv::Tv_FactoryGetColorTemp_Bgain ( int source_type, int colortemp_mode )
3412{
3413 return mVpp.Tv_FactoryGetColorTemp_Bgain(source_type, colortemp_mode);
3414}
3415
3416int CTv::Tv_FactorySetColorTemp_Roffset ( int source_type, int colortemp_mode, int roffset )
3417{
3418 return mVpp.Tv_FactorySetColorTemp_Roffset(source_type, colortemp_mode, roffset);
3419}
3420
3421int CTv::Tv_FactorySaveColorTemp_Roffset ( int source_type, int colortemp_mode, int roffset )
3422{
3423 return mVpp.Tv_FactorySaveColorTemp_Roffset(source_type, colortemp_mode, roffset);
3424}
3425
3426int CTv::Tv_FactoryGetColorTemp_Roffset ( int source_type, int colortemp_mode )
3427{
3428 return mVpp.Tv_FactoryGetColorTemp_Roffset(source_type, colortemp_mode);
3429}
3430
3431int CTv::Tv_FactorySetColorTemp_Goffset ( int source_type, int colortemp_mode, int goffset )
3432{
3433 return mVpp.Tv_FactorySetColorTemp_Goffset(source_type, colortemp_mode, goffset);
3434}
3435
3436int CTv::Tv_FactorySaveColorTemp_Goffset ( int source_type, int colortemp_mode, int goffset )
3437{
3438 return mVpp.Tv_FactorySaveColorTemp_Goffset(source_type, colortemp_mode, goffset);
3439}
3440
3441int CTv::Tv_FactoryGetColorTemp_Goffset ( int source_type, int colortemp_mode )
3442{
3443 return mVpp.Tv_FactoryGetColorTemp_Goffset(source_type, colortemp_mode);
3444}
3445
3446int CTv::Tv_FactorySetColorTemp_Boffset ( int source_type, int colortemp_mode, int boffset )
3447{
3448 return mVpp.Tv_FactorySetColorTemp_Boffset(source_type, colortemp_mode, boffset);
3449}
3450
3451int CTv::Tv_FactorySaveColorTemp_Boffset ( int source_type, int colortemp_mode, int boffset )
3452{
3453 return mVpp.Tv_FactorySaveColorTemp_Boffset(source_type, colortemp_mode, boffset);
3454}
3455
3456int CTv::Tv_FactoryGetColorTemp_Boffset ( int source_type, int colortemp_mode )
3457{
3458 return mVpp.Tv_FactoryGetColorTemp_Boffset(source_type, colortemp_mode);
3459}
3460
3461int CTv::GetColorTemperatureParams ( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params )
3462{
3463 return mVpp.GetColorTemperatureParams(Tempmode, params);
3464}
3465
3466int CTv::Tv_FactorySetTestPattern ( int pattern )
3467{
3468 switch ( pattern ) {
3469 case VPP_TEST_PATTERN_NONE:
3470 mAv.SetVideoScreenColor ( 3, 16, 128, 128 );
3471 break;
3472
3473 case VPP_TEST_PATTERN_RED:
3474 mAv.SetVideoScreenColor ( 0, 81, 90, 240 );
3475 break;
3476
3477 case VPP_TEST_PATTERN_GREEN:
3478 mAv.SetVideoScreenColor ( 0, 145, 54, 34 );
3479 break;
3480
3481 case VPP_TEST_PATTERN_BLUE:
3482 mAv.SetVideoScreenColor ( 0, 41, 240, 110 );
3483 break;
3484
3485 case VPP_TEST_PATTERN_WHITE:
3486 mAv.SetVideoScreenColor ( 0, 235, 128, 128 );
3487 break;
3488
3489 case VPP_TEST_PATTERN_BLACK:
3490 mAv.SetVideoScreenColor ( 0, 16, 128, 128 );
3491 break;
3492
3493 default:
3494 return -1;
3495 }
3496 return SSMSaveTestPattern ( pattern );
3497}
3498
3499int CTv::Tv_FactoryGetTestPattern ( void )
3500{
3501 return mVpp.Tv_FactoryGetTestPattern();
3502}
3503
3504int CTv::Tv_FactoryResetPQMode ( void )
3505{
3506 return mVpp.Tv_FactoryResetPQMode();
3507}
3508
3509int CTv::Tv_FactoryResetColorTemp ( void )
3510{
3511 return mVpp.Tv_FactoryResetColorTemp();
3512}
3513
3514int CTv::Tv_FactorySetParamsDefault ( void )
3515{
3516 return mVpp.Tv_FactorySetParamsDefault();
3517}
3518
3519int CTv::Tv_FactorySetDDRSSC ( int step )
3520{
3521 return mVpp.Tv_FactorySetDDRSSC(step);
3522}
3523
3524int CTv::Tv_FactoryGetDDRSSC ( void )
3525{
3526 return mVpp.Tv_FactoryGetDDRSSC();
3527}
3528
3529int CTv::Tv_FactorySetLVDSSSC ( int step )
3530{
3531 return mVpp.Tv_FactorySetLVDSSSC(step);
3532}
3533
3534int CTv::Tv_FactoryGetLVDSSSC ( void )
3535{
3536 return mVpp.Tv_FactoryGetLVDSSSC();
3537}
3538
3539int CTv::Tv_FactorySetNolineParams ( int noline_params_type, int source_type, noline_params_t noline_params )
3540{
3541 return mVpp.Tv_FactorySetNolineParams(noline_params_type, source_type, noline_params);
3542}
3543
3544noline_params_t CTv::Tv_FactoryGetNolineParams ( int noline_params_type, int source_type )
3545{
3546 return mVpp.Tv_FactoryGetNolineParams(noline_params_type, source_type);
3547}
3548
3549int CTv::Tv_FactorySetOverscan ( int source_type, int fmt, int status_3d, int trans_fmt, tvin_cutwin_t cutwin_t )
3550{
3551 //tvin_cutwin_t cutwin_t = mVpp.Tv_FactoryGetOverscan(source_type, fmt, status_3d, trans_fmt);
3552 return mVpp.VPP_SetVideoCrop ( ( int ) cutwin_t.vs, ( int ) cutwin_t.hs, ( int ) cutwin_t.ve, ( int ) cutwin_t.he );
3553}
3554
3555tvin_cutwin_t CTv::Tv_FactoryGetOverscan ( int source_type, int fmt, int status_3d, int trans_fmt )
3556{
3557 return mVpp.Tv_FactoryGetOverscan(source_type, fmt, Check2Dor3D(m_mode_3d, (tvin_trans_fmt_t)trans_fmt), trans_fmt);
3558}
3559
3560int CTv::Tv_FactorySet_FBC_Brightness ( int value )
3561{
3562 //int temp_value = (255*value)/100;
3563 int temp_value = value;
3564
3565 CFbcCommunication *fbcIns = GetSingletonFBC();
3566 if (fbcIns != NULL) {
3567 fbcIns->cfbc_Set_Brightness(COMM_DEV_SERIAL, temp_value);
3568 return 0;
3569 }
3570
3571 return -1;
3572}
3573
3574int CTv::Tv_FactoryGet_FBC_Brightness ( void )
3575{
3576 int temp_value = 0;
3577 int data = 0;
3578
3579 CFbcCommunication *fbcIns = GetSingletonFBC();
3580 if (fbcIns != NULL) {
3581 fbcIns->cfbc_Get_Brightness(COMM_DEV_SERIAL, &temp_value);
3582 //data = (temp_value*100)/255;
3583 data = temp_value;
3584
3585 return data;
3586 }
3587
3588 return 0;
3589}
3590
3591int CTv::Tv_FactorySet_FBC_Contrast ( int value )
3592{
3593 //int temp_value = (255*value)/100;
3594 int temp_value = value;
3595
3596 CFbcCommunication *fbcIns = GetSingletonFBC();
3597 if (fbcIns != NULL) {
3598 fbcIns->cfbc_Set_Contrast(COMM_DEV_SERIAL, temp_value);
3599 return 0;
3600 }
3601
3602 return -1;
3603}
3604
3605int CTv::Tv_FactoryGet_FBC_Contrast ( void )
3606{
3607 int temp_value = 0;
3608 int data = 0;
3609
3610 CFbcCommunication *fbcIns = GetSingletonFBC();
3611 if (fbcIns != NULL) {
3612 fbcIns->cfbc_Get_Contrast(COMM_DEV_SERIAL, &temp_value);
3613 //data = (temp_value*100)/255;
3614 data = temp_value;
3615
3616 return data;
3617 }
3618
3619 return 0;
3620}
3621
3622int CTv::Tv_FactorySet_FBC_Saturation ( int value )
3623{
3624 //int temp_value = (255*value)/100;
3625 int temp_value = value;
3626
3627 CFbcCommunication *fbcIns = GetSingletonFBC();
3628 if (fbcIns != NULL) {
3629 fbcIns->cfbc_Set_Saturation(COMM_DEV_SERIAL, temp_value);
3630 return 0;
3631 }
3632
3633 return -1;
3634}
3635
3636int CTv::Tv_FactoryGet_FBC_Saturation ( void )
3637{
3638 int temp_value = 0;
3639 int data = 0;
3640
3641 CFbcCommunication *fbcIns = GetSingletonFBC();
3642 if (fbcIns != NULL) {
3643 fbcIns->cfbc_Get_Saturation(COMM_DEV_SERIAL, &temp_value);
3644 //data = (temp_value*100)/255;
3645 data = temp_value;
3646
3647 return data;
3648 }
3649
3650 return 0;
3651}
3652
3653int CTv::Tv_FactorySet_FBC_HueColorTint ( int value )
3654{
3655 //int temp_value = (255*value)/100;
3656 int temp_value = value;
3657
3658 CFbcCommunication *fbcIns = GetSingletonFBC();
3659 if (fbcIns != NULL) {
3660 fbcIns->cfbc_Set_HueColorTint(COMM_DEV_SERIAL, temp_value);
3661 return 0;
3662 }
3663
3664 return -1;
3665}
3666
3667int CTv::Tv_FactoryGet_FBC_HueColorTint ( void )
3668{
3669 int temp_value = 0;
3670 int data = 0;
3671
3672 CFbcCommunication *fbcIns = GetSingletonFBC();
3673 if (fbcIns != NULL) {
3674 fbcIns->cfbc_Get_HueColorTint(COMM_DEV_SERIAL, &temp_value);
3675 //data = (temp_value*100)/255;
3676 data = temp_value;
3677
3678 return data;
3679 }
3680
3681 return 0;
3682}
3683
3684int CTv::Tv_FactorySet_FBC_Backlight ( int value )
3685{
3686 int temp_value = value;
3687 CFbcCommunication *fbcIns = GetSingletonFBC();
3688 if (fbcIns != NULL) {
3689 fbcIns->cfbc_Set_Backlight(COMM_DEV_SERIAL, temp_value);
3690 return 0;
3691 }
3692
3693 return -1;
3694}
3695
3696int CTv::Tv_FactoryGet_FBC_Backlight ( void )
3697{
3698 int temp_value = 0;
3699 int data = 0;
3700
3701 CFbcCommunication *fbcIns = GetSingletonFBC();
3702 if (fbcIns != NULL) {
3703 fbcIns->cfbc_Get_Backlight(COMM_DEV_SERIAL, &temp_value);
3704 data = temp_value;
3705
3706 return data;
3707 }
3708
3709 return 0;
3710}
3711
3712int CTv::Tv_FactorySet_FBC_Backlight_N360 ( int value )
3713{
3714 int val = 0;
3715
3716 CFbcCommunication *fbcIns = GetSingletonFBC();
3717 if (fbcIns != NULL) {
3718 fbcIns->cfbc_Set_AUTO_ELEC_MODE(COMM_DEV_SERIAL, value);
3719 val = value;
3720 SSMSaveFBCN360BackLightVal(val);
3721 return 0;
3722 }
3723
3724 return -1;
3725}
3726
3727int CTv::Tv_FactoryGet_FBC_Backlight_N360 ( void )
3728{
3729 int temp_value = 0;
3730 int val = 0;
3731
3732 SSMReadFBCN360BackLightVal(&val);
3733
3734 return val;
3735
3736}
3737
3738
3739int CTv::Tv_FactorySet_FBC_ELEC_MODE( int value )
3740{
3741 int val = 0;
3742
3743 CFbcCommunication *fbcIns = GetSingletonFBC();
3744 if (fbcIns != NULL) {
3745 fbcIns->cfbc_Set_AUTO_ELEC_MODE(COMM_DEV_SERIAL, value);
3746 val = value;
3747 SSMSaveFBCELECmodeVal(val);
3748 return 0;
3749 }
3750
3751 return -1;
3752}
3753
3754int CTv::Tv_FactoryGet_FBC_ELEC_MODE( void )
3755{
3756 int val = 0;
3757
3758 SSMReadFBCELECmodeVal(&val);
3759
3760 return val;
3761}
3762
3763int CTv::Tv_FactorySet_FBC_Thermal_State( int value )
3764{
3765 CFbcCommunication *fbcIns = GetSingletonFBC();
3766 if (fbcIns != NULL) {
3767 fbcIns->cfbc_Set_Thermal_state(COMM_DEV_SERIAL, value);
3768 return 0;
3769 }
3770
3771 return -1;
3772}
3773
3774int CTv::Tv_FactorySet_FBC_Picture_Mode ( int mode )
3775{
3776 CFbcCommunication *fbcIns = GetSingletonFBC();
3777 if (fbcIns != NULL) {
3778 fbcIns->cfbc_Set_Picture_Mode(COMM_DEV_SERIAL, mode);
3779 return 0;
3780 }
3781
3782 return -1;
3783}
3784
3785int CTv::Tv_FactoryGet_FBC_Picture_Mode ( void )
3786{
3787 int mode = 0;
3788
3789 CFbcCommunication *fbcIns = GetSingletonFBC();
3790 if (fbcIns != NULL) {
3791 fbcIns->cfbc_Get_Picture_Mode(COMM_DEV_SERIAL, &mode);
3792 return mode;
3793 }
3794
3795 return 0;
3796}
3797
3798int CTv::Tv_FactorySet_FBC_Set_Test_Pattern ( int mode )
3799{
3800 CFbcCommunication *fbcIns = GetSingletonFBC();
3801 if (fbcIns != NULL) {
3802 fbcIns->cfbc_Set_Test_Pattern(COMM_DEV_SERIAL, mode);
3803 return 0;
3804 }
3805
3806 return -1;
3807}
3808
3809int CTv::Tv_FactoryGet_FBC_Get_Test_Pattern ( void )
3810{
3811 int mode = 0;
3812
3813 CFbcCommunication *fbcIns = GetSingletonFBC();
3814 if (fbcIns != NULL) {
3815 fbcIns->cfbc_Get_Test_Pattern(COMM_DEV_SERIAL, &mode);
3816 return mode;
3817 }
3818
3819 return 0;
3820}
3821
3822
3823int CTv::Tv_FactorySet_FBC_Gain_Red( int value )
3824{
3825 int temp_value = 0;
3826
3827 //temp_value = (value*255)/2047;
3828 //value 0 ~ 2047
3829 temp_value = value;
3830
3831 CFbcCommunication *fbcIns = GetSingletonFBC();
3832 if (fbcIns != NULL) {
3833 fbcIns->cfbc_Set_Gain_Red(COMM_DEV_SERIAL, temp_value);
3834 return 0;
3835 }
3836
3837 return -1;
3838}
3839
3840int CTv::Tv_FactoryGet_FBC_Gain_Red ( void )
3841{
3842 int temp_value = 0, value = 0;
3843
3844 CFbcCommunication *fbcIns = GetSingletonFBC();
3845 if (fbcIns != NULL) {
3846 fbcIns->cfbc_Get_Gain_Red(COMM_DEV_SERIAL, &temp_value);
3847 //value 0 ~ 2047
3848 //value = (temp_value*2047)/255;
3849 value = temp_value;
3850
3851 return value;
3852 }
3853
3854 return 0;
3855}
3856
3857int CTv::Tv_FactorySet_FBC_Gain_Green( int value )
3858{
3859 int temp_value = 0;
3860
3861 //temp_value = (value*255)/2047;
3862 //value 0 ~ 2047
3863 temp_value = value;
3864
3865 CFbcCommunication *fbcIns = GetSingletonFBC();
3866 if (fbcIns != NULL) {
3867 fbcIns->cfbc_Set_Gain_Green(COMM_DEV_SERIAL, temp_value);
3868 return 0;
3869 }
3870
3871 return -1;
3872}
3873
3874int CTv::Tv_FactoryGet_FBC_Gain_Green ( void )
3875{
3876 int temp_value = 0, value = 0;
3877
3878 CFbcCommunication *fbcIns = GetSingletonFBC();
3879 if (fbcIns != NULL) {
3880 fbcIns->cfbc_Get_Gain_Green(COMM_DEV_SERIAL, &temp_value);
3881 //value 0 ~ 2047
3882 //value = (temp_value*2047)/255;
3883 value = temp_value;
3884
3885 return value;
3886 }
3887
3888 return 0;
3889}
3890
3891int CTv::Tv_FactorySet_FBC_Gain_Blue( int value )
3892{
3893 int temp_value = 0;
3894
3895 //temp_value = (value*255)/2047;
3896 //value 0 ~ 2047
3897 temp_value = value;
3898
3899 CFbcCommunication *fbcIns = GetSingletonFBC();
3900 if (fbcIns != NULL) {
3901 fbcIns->cfbc_Set_Gain_Blue(COMM_DEV_SERIAL, temp_value);
3902 return 0;
3903 }
3904
3905 return -1;
3906}
3907
3908int CTv::Tv_FactoryGet_FBC_Gain_Blue ( void )
3909{
3910 int temp_value = 0, value = 0;
3911
3912 CFbcCommunication *fbcIns = GetSingletonFBC();
3913 if (fbcIns != NULL) {
3914 fbcIns->cfbc_Get_Gain_Blue(COMM_DEV_SERIAL, &temp_value);
3915 //value 0 ~ 2047
3916 //value = (temp_value*2047)/255;
3917 value = temp_value;
3918
3919 return value;
3920 }
3921
3922 return 0;
3923}
3924
3925int CTv::Tv_FactorySet_FBC_Offset_Red( int value )
3926{
3927 //value -1024~+1023
3928 int temp_value = 0;
3929
3930 //temp_value = (value+1024)*255/2047;
3931 temp_value = value;
3932
3933 CFbcCommunication *fbcIns = GetSingletonFBC();
3934 if (fbcIns != NULL) {
3935 fbcIns->cfbc_Set_Offset_Red(COMM_DEV_SERIAL, temp_value);
3936 return 0;
3937 }
3938
3939 return -1;
3940}
3941
3942int CTv::Tv_FactoryGet_FBC_Offset_Red ( void )
3943{
3944 int temp_value = 0, value = 0;
3945
3946 CFbcCommunication *fbcIns = GetSingletonFBC();
3947 if (fbcIns != NULL) {
3948 fbcIns->cfbc_Get_Offset_Red(COMM_DEV_SERIAL, &temp_value);
3949 //value -1024~+1023
3950 //value = (temp_value*2047)/255 - 1024;
3951 value = temp_value;
3952
3953 return value;
3954 }
3955
3956 return 0;
3957}
3958
3959int CTv::Tv_FactorySet_FBC_Offset_Green( int value )
3960{
3961 //value -1024~+1023
3962 int temp_value = 0;
3963
3964 //temp_value = (value+1024)*255/2047;
3965 temp_value = value;
3966
3967 CFbcCommunication *fbcIns = GetSingletonFBC();
3968 if (fbcIns != NULL) {
3969 fbcIns->cfbc_Set_Offset_Green(COMM_DEV_SERIAL, temp_value);
3970 return 0;
3971 }
3972
3973 return -1;
3974}
3975
3976int CTv::Tv_FactoryGet_FBC_Offset_Green ( void )
3977{
3978 int temp_value = 0, value = 0;
3979
3980 CFbcCommunication *fbcIns = GetSingletonFBC();
3981 if (fbcIns != NULL) {
3982 fbcIns->cfbc_Get_Offset_Green(COMM_DEV_SERIAL, &temp_value);
3983 //value -1024~+1023
3984 //value = (temp_value*2047)/255 - 1024;
3985 value = temp_value;
3986
3987 return value;
3988 }
3989
3990 return 0;
3991}
3992
3993int CTv::Tv_FactorySet_FBC_Offset_Blue( int value )
3994{
3995 //value -1024~+1023
3996 int temp_value = 0;
3997
3998 //temp_value = (value+1024)*255/2047;
3999 temp_value = value;
4000
4001 CFbcCommunication *fbcIns = GetSingletonFBC();
4002 if (fbcIns != NULL) {
4003 fbcIns->cfbc_Set_Offset_Blue(COMM_DEV_SERIAL, value);
4004 return 0;
4005 }
4006
4007 return -1;
4008}
4009
4010int CTv::Tv_FactoryGet_FBC_Offset_Blue ( void )
4011{
4012 int temp_value = 0, value = 0;
4013
4014 CFbcCommunication *fbcIns = GetSingletonFBC();
4015 if (fbcIns != NULL) {
4016 fbcIns->cfbc_Get_Offset_Blue(COMM_DEV_SERIAL, &temp_value);
4017 //value -1024~+1023
4018 //value = (temp_value*2047)/255 - 1024;
4019 value = temp_value;
4020
4021 return value;
4022 }
4023
4024 return 0;
4025}
4026
4027int CTv::Tv_FactoryGetWhiteBalanceRedGain(int source_type, int colortemp_mode)
4028{
4029 int useFbc = 0;
4030 int ret = -1;
4031 useFbc = GetPlatformHaveFBCFlag();
4032 if (useFbc == 0) { // not use fbc store the white balance params
4033 LOGD("--------- call none fbc method ---------");
4034 ret = mVpp.Tv_FactoryGetColorTemp_Rgain(source_type, colortemp_mode);
4035 } else { //use fbc store the white balance params
4036 LOGD("--------- call fbc method ---------");
4037 colortemp_mode = Tv_FactoryWhiteBalanceColorTempMappingG92Fbc(colortemp_mode);
4038 ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 0);
4039 }
4040 return ret;
4041}
4042
4043int CTv::Tv_FactoryGetWhiteBalanceGreenGain(int source_type, int colortemp_mode)
4044{
4045 int useFbc = 0;
4046 int ret = -1;
4047 useFbc = GetPlatformHaveFBCFlag();
4048 if (useFbc == 0) { // not use fbc store the white balance params
4049 ret = mVpp.Tv_FactoryGetColorTemp_Ggain(source_type, colortemp_mode);
4050 } else { //use fbc store the white balance params
4051 colortemp_mode = Tv_FactoryWhiteBalanceColorTempMappingG92Fbc(colortemp_mode);
4052 ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 1);
4053 }
4054 return ret;
4055}
4056
4057int CTv::Tv_FactoryGetWhiteBalanceBlueGain(int source_type, int colortemp_mode)
4058{
4059 int useFbc = 0;
4060 int ret = -1;
4061 useFbc = GetPlatformHaveFBCFlag();
4062 if (useFbc == 0) { // not use fbc store the white balance params
4063 ret = mVpp.Tv_FactoryGetColorTemp_Bgain(source_type, colortemp_mode);
4064 } else { //use fbc store the white balance params
4065 colortemp_mode = Tv_FactoryWhiteBalanceColorTempMappingG92Fbc(colortemp_mode);
4066 ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 2);
4067 }
4068 return ret;
4069}
4070
4071int CTv::Tv_FactoryGetWhiteBalanceRedOffset(int source_type, int colortemp_mode)
4072{
4073 int useFbc = 0;
4074 int ret = -1;
4075 useFbc = GetPlatformHaveFBCFlag();
4076 if (useFbc == 0) { // not use fbc store the white balance params
4077 ret = mVpp.Tv_FactoryGetColorTemp_Roffset(source_type, colortemp_mode);
4078 } else { //use fbc store the white balance params
4079 colortemp_mode = Tv_FactoryWhiteBalanceColorTempMappingG92Fbc(colortemp_mode);
4080 ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 3);
4081 }
4082 return ret;
4083}
4084
4085int CTv::Tv_FactoryGetWhiteBalanceGreenOffset(int source_type, int colortemp_mode)
4086{
4087 int useFbc = 0;
4088 int ret = -1;
4089 useFbc = GetPlatformHaveFBCFlag();
4090 if (useFbc == 0) { // not use fbc store the white balance params
4091 ret = mVpp.Tv_FactoryGetColorTemp_Goffset(source_type, colortemp_mode);
4092 } else { //use fbc store the white balance params
4093 colortemp_mode = Tv_FactoryWhiteBalanceColorTempMappingG92Fbc(colortemp_mode);
4094 ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 4);
4095 }
4096 return ret;
4097}
4098
4099int CTv::Tv_FactoryGetWhiteBalanceBlueOffset(int source_type, int colortemp_mode)
4100{
4101 int useFbc = 0;
4102 int ret = -1;
4103 useFbc = GetPlatformHaveFBCFlag();
4104 if (useFbc == 0) { // not use fbc store the white balance params
4105 ret = mVpp.Tv_FactoryGetColorTemp_Boffset(source_type, colortemp_mode);
4106 } else { //use fbc store the white balance params
4107 colortemp_mode = Tv_FactoryWhiteBalanceColorTempMappingG92Fbc(colortemp_mode);
4108 ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 5);
4109 }
4110 return ret;
4111}
4112
4113int CTv::Tv_FactorySetWhiteBalanceRedGain(int source_type, int colortemp_mode, int value)
4114{
4115 int useFbc = 0;
4116 int ret = -1;
4117 useFbc = GetPlatformHaveFBCFlag();
4118 if (value < 0) {
4119 value = 0;
4120 } else if (value > 2047) {
4121 value = 2047;
4122 }
4123 if (useFbc == 0) { // not use fbc store the white balance params
4124 ret = mVpp.Tv_FactorySetColorTemp_Rgain(source_type, colortemp_mode, value);
4125 if (ret != -1) {
4126 LOGD("save the red gain to flash")
4127 ret = mVpp.Tv_FactorySaveColorTemp_Rgain(source_type, colortemp_mode, value);
4128 }
4129 } else { //use fbc store the white balance params
4130 value = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(value);
4131 ret = Tv_FactorySet_FBC_Gain_Red(value);
4132 }
4133 return ret;
4134}
4135
4136int CTv::Tv_FactorySetWhiteBalanceGreenGain(int source_type, int colortemp_mode, int value)
4137{
4138 int useFbc = 0;
4139 int ret = -1;
4140 useFbc = GetPlatformHaveFBCFlag();
4141 if (value < 0) {
4142 value = 0;
4143 } else if (value > 2047) {
4144 value = 2047;
4145 }
4146 if (useFbc == 0) { // not use fbc store the white balance params
4147 ret = mVpp.Tv_FactorySetColorTemp_Ggain(source_type, colortemp_mode, value);
4148 if (ret != -1) {
4149 LOGD("save the green gain to flash")
4150 ret = mVpp.Tv_FactorySaveColorTemp_Ggain(source_type, colortemp_mode, value);
4151 }
4152 } else { //use fbc store the white balance params
4153 value = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(value);
4154 ret = Tv_FactorySet_FBC_Gain_Green(value);
4155 }
4156 return ret;
4157}
4158
4159int CTv::Tv_FactorySetWhiteBalanceBlueGain(int source_type, int colortemp_mode, int value)
4160{
4161 int useFbc = 0;
4162 int ret = -1;
4163 useFbc = GetPlatformHaveFBCFlag();
4164 if (value < 0) {
4165 value = 0;
4166 } else if (value > 2047) {
4167 value = 2047;
4168 }
4169 if (useFbc == 0) { // not use fbc store the white balance params
4170 ret = mVpp.Tv_FactorySetColorTemp_Bgain(source_type, colortemp_mode, value);
4171 if (ret != -1) {
4172 LOGD("save the blue gain to flash")
4173 ret = mVpp.Tv_FactorySaveColorTemp_Bgain(source_type, colortemp_mode, value);
4174 }
4175 } else { //use fbc store the white balance params
4176 value = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(value);
4177 ret = Tv_FactorySet_FBC_Gain_Blue(value);
4178 }
4179 return ret;
4180}
4181
4182int CTv::Tv_FactorySetWhiteBalanceRedOffset(int source_type, int colortemp_mode, int value)
4183{
4184 int useFbc = 0;
4185 int ret = -1;
4186 if (value < -1024) {
4187 value = -1024;
4188 } else if (value > 1023) {
4189 value = 1023;
4190 }
4191 useFbc = GetPlatformHaveFBCFlag();
4192 if (useFbc == 0) { // not use fbc store the white balance params
4193 ret = mVpp.Tv_FactorySetColorTemp_Roffset(source_type, colortemp_mode, value);
4194 if (ret != -1) {
4195 LOGD("save the red offset to flash")
4196 ret = mVpp.Tv_FactorySaveColorTemp_Roffset(source_type, colortemp_mode, value);
4197 }
4198 } else { //use fbc store the white balance params
4199 value = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(value);
4200 ret = Tv_FactorySet_FBC_Offset_Red(value);
4201 }
4202 return ret;
4203}
4204
4205int CTv::Tv_FactorySetWhiteBalanceGreenOffset(int source_type, int colortemp_mode, int value)
4206{
4207 int useFbc = 0;
4208 int ret = -1;
4209 if (value < -1024) {
4210 value = -1024;
4211 } else if (value > 1023) {
4212 value = 1023;
4213 }
4214 useFbc = GetPlatformHaveFBCFlag();
4215 if (useFbc == 0) { // not use fbc store the white balance params
4216 ret = mVpp.Tv_FactorySetColorTemp_Goffset(source_type, colortemp_mode, value);
4217 if (ret != -1) {
4218 LOGD("save the green offset to flash")
4219 ret = mVpp.Tv_FactorySaveColorTemp_Goffset(source_type, colortemp_mode, value);
4220 }
4221 } else { //use fbc store the white balance params
4222 value = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(value);
4223 ret = Tv_FactorySet_FBC_Offset_Green(value);
4224 }
4225 return ret;
4226}
4227
4228int CTv::Tv_FactorySetWhiteBalanceBlueOffset(int source_type, int colortemp_mode, int value)
4229{
4230 int useFbc = 0;
4231 int ret = -1;
4232 useFbc = GetPlatformHaveFBCFlag();
4233 if (value < -1024) {
4234 value = -1024;
4235 } else if (value > 1023) {
4236 value = 1023;
4237 }
4238 if (useFbc == 0) { // not use fbc store the white balance params
4239 ret = mVpp.Tv_FactorySetColorTemp_Boffset(source_type, colortemp_mode, value);
4240 if (ret != -1) {
4241 LOGD("save the blue offset to flash")
4242 ret = mVpp.Tv_FactorySaveColorTemp_Boffset(source_type, colortemp_mode, value);
4243 }
4244 } else { //use fbc store the white balance params
4245 value = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(value);
4246 ret = Tv_FactorySet_FBC_Offset_Blue(value);
4247 }
4248 return ret;
4249}
4250
4251
4252int CTv::Tv_FactorySetWhiteBalanceColorTempMode(int source_type, int colortemp_mode, int is_save)
4253{
4254 int useFbc = 0;
4255 int ret = -1;
4256 int colorTemp = 0;
4257 useFbc = GetPlatformHaveFBCFlag();
4258 if (useFbc == 0) { // not use fbc store the white balance params
4259 ret = mVpp.Tv_SetColorTemperature((vpp_color_temperature_mode_t)colortemp_mode, (tv_source_input_type_t)source_type, is_save);
4260 } else { //use fbc store the white balance params
4261 colorTemp = Tv_FactoryWhiteBalanceColorTempMappingG92Fbc(colortemp_mode);
4262 ret = Tv_FactorySet_FBC_ColorTemp_Mode(colorTemp);
4263 }
4264 return ret;
4265}
4266
4267int CTv::Tv_FactoryGetWhiteBalanceColorTempMode(int source_type )
4268{
4269 int useFbc = 0;
4270 int ret = -1;
4271 useFbc = GetPlatformHaveFBCFlag();
4272 if (useFbc == 0) { // not use fbc store the white balance params
4273 ret = mVpp.Tv_GetColorTemperature((tv_source_input_type_t)source_type);
4274 } else { //use fbc store the white balance params
4275 ret = Tv_FactoryGet_FBC_ColorTemp_Mode();
4276 ret = Tv_FactoryWhiteBalanceColorTempMappingFbc2G9(ret);
4277 }
4278 return ret;
4279}
4280
4281int CTv::Tv_FactoryWhiteBalanceFormatInputFbcGainParams(int value)
4282{
4283 int ret = 1024;
4284 if (value < 0) {
4285 ret = 0;
4286 } else if (value > 2047) {
4287 ret = 2047;
4288 } else {
4289 ret = value;
4290 }
4291 ret = ret >> 3;
4292 return ret;
4293}
4294
4295int CTv::Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(int value)
4296{
4297 int ret = 0;
4298 if (value < -1024) {
4299 ret = -1024;
4300 } else if (value > 1023) {
4301 ret = 1023;
4302 } else {
4303 ret = value;
4304 }
4305 ret += 1024;
4306 ret = ret >> 3;
4307 return ret;
4308}
4309
4310int CTv::Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(int value)
4311{
4312 if (value == 255) {
4313 value = 1023;
4314 } else {
4315 value = value << 3;
4316 value -= 1024;
4317 }
4318 return value;
4319}
4320
4321int CTv::Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(int value)
4322{
4323 value = value << 3;
4324 if (value < 0) {
4325 value = 0;
4326 } else if (value > 2047) {
4327 value = 2047;
4328 }
4329 return value;
4330}
4331
4332
4333int CTv::Tv_FactorySaveWhiteBalancePramas(int source_type, int tempmode, int r_gain, int g_gain, int b_gain, int r_offset, int g_offset, int b_offset)
4334{
4335 int useFbc = 0;
4336 int ret = 0;
4337 useFbc = GetPlatformHaveFBCFlag();
4338 if (useFbc == 0) { // not use fbc store the white balance params
4339 mVpp.Tv_SaveColorTemp((vpp_color_temperature_mode_t) tempmode, (tv_source_input_type_t) source_type);
4340 mVpp.Tv_FactorySaveColorTemp_Rgain(source_type, tempmode, r_gain);
4341 mVpp.Tv_FactorySaveColorTemp_Ggain(source_type, tempmode, g_gain);
4342 mVpp.Tv_FactorySaveColorTemp_Bgain(source_type, tempmode, b_gain);
4343 mVpp.Tv_FactorySaveColorTemp_Roffset(source_type, tempmode, r_offset);
4344 mVpp.Tv_FactorySaveColorTemp_Goffset(source_type, tempmode, g_offset);
4345 mVpp.Tv_FactorySaveColorTemp_Boffset(source_type, tempmode, b_offset);
4346 } else { //use fbc store the white balance params
4347 tcon_rgb_ogo_t params;
4348
4349 params.r_gain = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(r_gain);
4350 params.g_gain = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(g_gain);
4351 params.b_gain = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(b_gain);
4352 params.r_post_offset = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(r_offset);
4353 params.g_post_offset = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(g_offset);
4354 params.b_post_offset = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(b_offset);
4355 tempmode = Tv_FactoryWhiteBalanceColorTempMappingG92Fbc(tempmode);
4356 ret = Tv_FactorySet_FBC_ColorTemp_Batch((vpp_color_temperature_mode_t)tempmode, params);
4357 }
4358 return ret;
4359}
4360
4361
4362int CTv::Tv_FactoryCloseWhiteBalanceGrayPattern()
4363{
4364 int useFbc = 0;
4365 int ret = -1;
4366 useFbc = GetPlatformHaveFBCFlag();
4367 if (useFbc == 0) { // not use fbc store the white balance params
4368 ret = mVpp.VPP_SetGrayPattern(0);
4369 } else { //use fbc store the white balance params
4370 ret = Tv_FactoryClose_FBC_GrayPattern();
4371 }
4372 return ret;
4373}
4374
4375int CTv::Tv_FactoryOpenWhiteBalanceGrayPattern()
4376{
4377 int useFbc = 0;
4378 int ret = -1;
4379 useFbc = GetPlatformHaveFBCFlag();
4380 if (useFbc == 0) { // not use fbc store the white balance params
4381 ret = 0;
4382 } else { //use fbc store the white balance params
4383 ret = Tv_FactoryOpen_FBC_GrayPattern();
4384 }
4385 return ret;
4386}
4387
4388int CTv::Tv_FactorySetWhiteBalanceGrayPattern(int value)
4389{
4390 int useFbc = 0;
4391 int ret = -1;
4392 useFbc = GetPlatformHaveFBCFlag();
4393 if (useFbc == 0) {
4394 ret = mVpp.VPP_SetGrayPattern(value);
4395 } else {
4396 ret = Tv_FactorySet_FBC_GrayPattern(value);
4397 }
4398 return ret;
4399}
4400
4401int CTv:: Tv_FactoryGetWhiteBalanceGrayPattern()
4402{
4403 int useFbc = 0;
4404 int ret = -1;
4405 useFbc = GetPlatformHaveFBCFlag();
4406 if (useFbc == 0) {
4407 ret = mVpp.VPP_GetGrayPattern();
4408 } else {
4409
4410 }
4411 return ret;
4412}
4413
4414
4415/**
4416* The color temperature enum order is diffrent bettewn G9 and Fbc, so we have to make a mapping
4417**/
4418int CTv::Tv_FactoryWhiteBalanceColorTempMappingG92Fbc(int Tempmode)
4419{
4420 int ret = Tempmode;
4421 switch (Tempmode) {
4422 case 0: //standard
4423 ret = 1;
4424 break;
4425 case 1: //warm
4426 ret = 2;
4427 break;
4428 case 2: //cold
4429 ret = 0;
4430 break;
4431 default:
4432 break;
4433 }
4434 return ret;
4435}
4436
4437/**
4438* The color temperature enum order is diffrent bettewn G9 and Fbc, so we have to make a mapping
4439**/
4440int CTv::Tv_FactoryWhiteBalanceColorTempMappingFbc2G9(int Tempmode)
4441{
4442 int ret = Tempmode;
4443 switch (Tempmode) {
4444 case 0: //cold
4445 ret = 2;
4446 break;
4447 case 1: //standard
4448 ret = 0;
4449 break;
4450 case 2: //warm
4451 ret = 1;
4452 break;
4453 default:
4454 break;
4455 }
4456 return ret;
4457}
4458
4459int CTv::Tv_FactoryWhiteBalanceGetAllParams(int Tempmode, tcon_rgb_ogo_t *params)
4460{
4461 int ret = -1;
4462 Tempmode = Tv_FactoryWhiteBalanceColorTempMappingG92Fbc(Tempmode);
4463 ret = Tv_FactoryGet_FBC_ColorTemp_Batch((vpp_color_temperature_mode_t)Tempmode, params);
4464 params->r_gain = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params->r_gain);
4465 params->g_gain = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params->g_gain);
4466 params->b_gain = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params->b_gain);
4467 params->r_post_offset = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params->r_post_offset);
4468 params->g_post_offset = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params->g_post_offset);
4469 params->b_post_offset = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params->b_post_offset);
4470 return ret;
4471}
4472
4473int CTv::Tv_FactorySet_FBC_GrayPattern(int value)
4474{
4475 int ret = -1;
4476 unsigned char grayValue = 0;
4477 if (value > 255) {
4478 grayValue = 255;
4479 } else if (value < 0) {
4480 grayValue = 0;
4481 } else {
4482 grayValue = (unsigned char)(0xFF & value);
4483 }
4484 CFbcCommunication *fbcIns = GetSingletonFBC();
4485 if (fbcIns != NULL) {
4486 ret = fbcIns->cfbc_WhiteBalance_SetGrayPattern(COMM_DEV_SERIAL, grayValue);
4487 }
4488 return ret;
4489}
4490
4491int CTv::Tv_FactoryOpen_FBC_GrayPattern()
4492{
4493 int ret = -1;
4494 CFbcCommunication *fbcIns = GetSingletonFBC();
4495 if (fbcIns != NULL) {
4496 ret = fbcIns->cfbc_WhiteBalance_GrayPattern_OnOff(COMM_DEV_SERIAL, 0);
4497 }
4498 return ret;
4499}
4500
4501int CTv::Tv_FactoryClose_FBC_GrayPattern()
4502{
4503 int ret = -1;
4504 CFbcCommunication *fbcIns = GetSingletonFBC();
4505 if (fbcIns != NULL) {
4506 ret = fbcIns->cfbc_WhiteBalance_GrayPattern_OnOff(COMM_DEV_SERIAL, 1);
4507 }
4508 return ret;
4509}
4510
4511int CTv::Tv_FactorySet_FBC_ColorTemp_Mode( int mode )
4512{
4513 CFbcCommunication *fbcIns = GetSingletonFBC();
4514 if (fbcIns != NULL) {
4515 fbcIns->cfbc_Set_ColorTemp_Mode(COMM_DEV_SERIAL, mode);
4516 return 0;
4517 }
4518
4519 return -1;
4520}
4521
4522int CTv::Tv_FactoryGet_FBC_ColorTemp_Mode ( void )
4523{
4524 int temp_mode = 0;
4525
4526 CFbcCommunication *fbcIns = GetSingletonFBC();
4527 if (fbcIns != NULL) {
4528 fbcIns->cfbc_Get_ColorTemp_Mode(COMM_DEV_SERIAL, &temp_mode);
4529 return temp_mode;
4530 }
4531
4532 return 0;
4533}
4534int CTv::Tv_FactorySet_FBC_ColorTemp_Mode_N360( int mode )
4535{
4536 CFbcCommunication *fbcIns = GetSingletonFBC();
4537 if (fbcIns != NULL) {
4538 fbcIns->cfbc_Set_ColorTemp_Mode(COMM_DEV_SERIAL, mode);
4539 SSMSaveFBCN360ColorTempVal(mode);
4540 return 0;
4541 }
4542
4543 return -1;
4544}
4545
4546int CTv::Tv_FactoryGet_FBC_ColorTemp_Mode_N360 ( void )
4547{
4548 int temp_mode = 0;
4549
4550 SSMReadFBCN360ColorTempVal(&temp_mode);
4551
4552 return temp_mode;
4553}
4554
4555int CTv::Tv_FactorySet_FBC_WB_Initial( int status )
4556{
4557 CFbcCommunication *fbcIns = GetSingletonFBC();
4558 if (fbcIns != NULL) {
4559 fbcIns->cfbc_Set_WB_Initial(COMM_DEV_SERIAL, status);
4560 return 0;
4561 }
4562
4563 return -1;
4564}
4565
4566int CTv::Tv_FactoryGet_FBC_WB_Initial ( void )
4567{
4568 int temp_status = 0;
4569
4570 CFbcCommunication *fbcIns = GetSingletonFBC();
4571 if (fbcIns != NULL) {
4572 fbcIns->cfbc_Get_WB_Initial(COMM_DEV_SERIAL, &temp_status);
4573 return temp_status;
4574 }
4575
4576 return 0;
4577}
4578
4579int CTv::Tv_FactorySet_FBC_ColorTemp_Batch(vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t params)
4580{
4581 unsigned char mode = 0, r_gain, g_gain, b_gain, r_offset, g_offset, b_offset;
4582 switch(Tempmode) {
4583 case VPP_COLOR_TEMPERATURE_MODE_STANDARD:
4584 mode = 1; //COLOR_TEMP_STD
4585 break;
4586 case VPP_COLOR_TEMPERATURE_MODE_WARM:
4587 mode = 2; //COLOR_TEMP_WARM
4588 break;
4589 case VPP_COLOR_TEMPERATURE_MODE_COLD:
4590 mode = 3; //COLOR_TEMP_COLD
4591 break;
4592 case VPP_COLOR_TEMPERATURE_MODE_USER:
4593 mode = 3; //COLOR_TEMP_USER
4594 break;
4595 }
4596 r_gain = (params.r_gain * 255) / 2047; // u1.10, range 0~2047, default is 1024 (1.0x)
4597 g_gain = (params.g_gain * 255) / 2047;
4598 b_gain = (params.b_gain * 255) / 2047;
4599 r_offset = (params.r_post_offset + 1024) * 255 / 2047; // s11.0, range -1024~+1023, default is 0
4600 g_offset = (params.g_post_offset + 1024) * 255 / 2047;
4601 b_offset = (params.b_post_offset + 1024) * 255 / 2047;
4602 LOGD ( "~Tv_FactorySet_FBC_ColorTemp_Batch##%d,%d,%d,%d,%d,%d,##", r_gain, g_gain, b_gain, r_offset, g_offset, b_offset );
4603
4604 CFbcCommunication *fbcIns = GetSingletonFBC();
4605 if (fbcIns != NULL) {
4606 fbcIns->cfbc_Set_WB_Batch(COMM_DEV_SERIAL, mode, r_gain, g_gain, b_gain, r_offset, g_offset, b_offset);
4607 return 0;
4608 }
4609
4610 return -1;
4611}
4612
4613int CTv::Tv_FactoryGet_FBC_ColorTemp_Batch ( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params )
4614{
4615 unsigned char mode = 0, r_gain, g_gain, b_gain, r_offset, g_offset, b_offset;
4616 switch(Tempmode) {
4617 case VPP_COLOR_TEMPERATURE_MODE_STANDARD:
4618 mode = 1; //COLOR_TEMP_STD
4619 break;
4620 case VPP_COLOR_TEMPERATURE_MODE_WARM:
4621 mode = 2; //COLOR_TEMP_WARM
4622 break;
4623 case VPP_COLOR_TEMPERATURE_MODE_COLD:
4624 mode = 3; //COLOR_TEMP_COLD
4625 break;
4626 case VPP_COLOR_TEMPERATURE_MODE_USER:
4627 mode = 3; //COLOR_TEMP_USER
4628 break;
4629 }
4630
4631 CFbcCommunication *fbcIns = GetSingletonFBC();
4632 if (fbcIns != NULL) {
4633 fbcIns->cfbc_Get_WB_Batch(COMM_DEV_SERIAL, mode, &r_gain, &g_gain, &b_gain, &r_offset, &g_offset, &b_offset);
4634 LOGD ( "~Tv_FactoryGet_FBC_ColorTemp_Batch##%d,%d,%d,%d,%d,%d,##", r_gain, g_gain, b_gain, r_offset, g_offset, b_offset );
4635
4636 params->r_gain = (r_gain * 2047) / 255;
4637 params->g_gain = (g_gain * 2047) / 255;
4638 params->b_gain = (b_gain * 2047) / 255;
4639 params->r_post_offset = (r_offset * 2047) / 255 - 1024;
4640 params->g_post_offset = (g_offset * 2047) / 255 - 1024;
4641 params->b_post_offset = (b_offset * 2047) / 255 - 1024;
4642
4643 return 0;
4644 }
4645
4646 return -1;
4647}
4648
4649int CTv::Tv_FactorySet_WB_G9_To_FBC( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t params )
4650{
4651 Tv_FactorySet_FBC_ColorTemp_Batch(Tempmode, params);
4652
4653 return 0;
4654}
4655
4656int CTv::Tv_FactoryGet_WB_G9_To_FBC ( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params )
4657{
4658 int temp_status = 0;
4659
4660 Tv_FactoryGet_FBC_ColorTemp_Batch(Tempmode, params);
4661
4662 return temp_status;
4663}
4664
4665int CTv::Tv_FactoryGetItemFromBatch(vpp_color_temperature_mode_t colortemp_mode, int item)
4666{
4667 tcon_rgb_ogo_t params;
4668 int ret = 0;
4669
4670 Tv_FactoryGet_FBC_ColorTemp_Batch((vpp_color_temperature_mode_t)colortemp_mode, &params);
4671 switch(item) {
4672 case 0:
4673 ret = params.r_gain;
4674 ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(ret);
4675 break;
4676 case 1:
4677 ret = params.g_gain;
4678 ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(ret);
4679 break;
4680 case 2:
4681 ret = params.b_gain;
4682 ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(ret);
4683 break;
4684 case 3:
4685 ret = params.r_post_offset;
4686 ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(ret);
4687 break;
4688 case 4:
4689 ret = params.g_post_offset;
4690 ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(ret);
4691 break;
4692 case 5:
4693 ret = params.b_post_offset;
4694 ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(ret);
4695 break;
4696 default:
4697 ret = 0;
4698 }
4699 return ret;
4700
4701}
4702
4703
4704int CTv::Tv_FactorySet_FBC_CM_OnOff( unsigned char status )
4705{
4706 CFbcCommunication *fbcIns = GetSingletonFBC();
4707 if (fbcIns != NULL) {
4708 fbcIns->cfbc_Set_CM(COMM_DEV_SERIAL, status);
4709 return 0;
4710 }
4711
4712 return -1;
4713}
4714
4715int CTv::Tv_FactoryGet_FBC_CM_OnOff (void)
4716{
4717 int temp_status = 0;
4718
4719 CFbcCommunication *fbcIns = GetSingletonFBC();
4720 if (fbcIns != NULL) {
4721 fbcIns->cfbc_Get_CM(COMM_DEV_SERIAL, &temp_status);
4722 return temp_status;
4723 }
4724
4725 return 0;
4726}
4727
4728int CTv::Tv_FactorySet_FBC_DNLP_OnOff( unsigned char status )
4729{
4730 CFbcCommunication *fbcIns = GetSingletonFBC();
4731 if (fbcIns != NULL) {
4732 fbcIns->cfbc_Set_DNLP(COMM_DEV_SERIAL, status);
4733 return 0;
4734 }
4735
4736 return -1;
4737}
4738
4739int CTv::Tv_FactoryGet_FBC_DNLP_OnOff (void)
4740{
4741 int temp_status = 0;
4742
4743 CFbcCommunication *fbcIns = GetSingletonFBC();
4744 if (fbcIns != NULL) {
4745 fbcIns->cfbc_Get_DNLP(COMM_DEV_SERIAL, &temp_status);
4746 return temp_status;
4747 }
4748
4749 return 0;
4750}
4751
4752int CTv::Tv_FactorySet_FBC_Gamma_OnOff( unsigned char status )
4753{
4754 CFbcCommunication *fbcIns = GetSingletonFBC();
4755 if (fbcIns != NULL) {
4756 fbcIns->cfbc_Set_Gamma(COMM_DEV_SERIAL, status);
4757 return 0;
4758 }
4759
4760 return -1;
4761}
4762
4763int CTv::Tv_FactoryGet_FBC_Gamma_OnOff (void)
4764{
4765 int temp_status = 0;
4766
4767 CFbcCommunication *fbcIns = GetSingletonFBC();
4768 if (fbcIns != NULL) {
4769 fbcIns->cfbc_Get_Gamma(COMM_DEV_SERIAL, &temp_status);
4770 return temp_status;
4771 }
4772
4773 return 0;
4774}
4775
4776int CTv::Tv_FactorySet_FBC_WhiteBalance_OnOff( unsigned char status )
4777{
4778 CFbcCommunication *fbcIns = GetSingletonFBC();
4779 if (fbcIns != NULL) {
4780 fbcIns->cfbc_Set_WhiteBalance_OnOff(COMM_DEV_SERIAL, status);
4781 return 0;
4782 }
4783
4784 return -1;
4785}
4786
4787int CTv::Tv_FactoryGet_FBC_WhiteBalance_OnOff (void)
4788{
4789 int temp_status = 0;
4790
4791 CFbcCommunication *fbcIns = GetSingletonFBC();
4792 if (fbcIns != NULL) {
4793 fbcIns->cfbc_Get_WhiteBalance_OnOff(COMM_DEV_SERIAL, &temp_status);
4794 return temp_status;
4795 }
4796
4797 return 0;
4798}
4799
4800
4801int CTv::Tv_FactorySet_FBC_backlight_onoff ( int value )
4802{
4803 CFbcCommunication *fbcIns = GetSingletonFBC();
4804 if (fbcIns != NULL) {
4805 fbcIns->cfbc_Set_backlight_onoff(COMM_DEV_SERIAL, value);
4806 return 0;
4807 }
4808
4809 return -1;
4810}
4811
4812int CTv::Tv_FactoryGet_FBC_backlight_onoff ( void )
4813{
4814 int temp_value = 0;
4815
4816 CFbcCommunication *fbcIns = GetSingletonFBC();
4817 if (fbcIns != NULL) {
4818 fbcIns->cfbc_Get_backlight_onoff(COMM_DEV_SERIAL, &temp_value);
4819 return temp_value;
4820 }
4821
4822 return 0;
4823}
4824
4825int CTv::Tv_FactorySet_FBC_LVDS_SSG_Set( int value )
4826{
4827 CFbcCommunication *fbcIns = GetSingletonFBC();
4828 if (fbcIns != NULL) {
4829 fbcIns->cfbc_Set_LVDS_SSG_Set(COMM_DEV_SERIAL, value);
4830 return 0;
4831 }
4832
4833 return -1;
4834}
4835
4836int CTv::Tv_FactorySet_FBC_LightSensor_Status_N310 ( int value )
4837{
4838 int temp_value = value;
4839
4840 CFbcCommunication *fbcIns = GetSingletonFBC();
4841 if (fbcIns != NULL) {
4842 fbcIns->cfbc_Set_LightSensor_N310(COMM_DEV_SERIAL, temp_value);
4843 return 0;
4844 }
4845
4846 return -1;
4847}
4848
4849int CTv::Tv_FactoryGet_FBC_LightSensor_Status_N310 ( void )
4850{
4851 int temp_value = 0;
4852 int data = 0;
4853
4854 CFbcCommunication *fbcIns = GetSingletonFBC();
4855 if (fbcIns != NULL) {
4856 fbcIns->cfbc_Get_LightSensor_N310(COMM_DEV_SERIAL, &temp_value);
4857
4858 data = temp_value;
4859
4860 return data;
4861 }
4862
4863 return 0;
4864}
4865int CTv::Tv_FactorySet_FBC_Dream_Panel_Status_N310 ( int value )
4866{
4867 int temp_value = value;
4868
4869 CFbcCommunication *fbcIns = GetSingletonFBC();
4870 if (fbcIns != NULL) {
4871 fbcIns->cfbc_Set_Dream_Panel_N310(COMM_DEV_SERIAL, temp_value);
4872 return 0;
4873 }
4874
4875 return -1;
4876}
4877
4878int CTv::Tv_FactoryGet_FBC_Dream_Panel_Status_N310 ( void )
4879{
4880 int temp_value = 0;
4881 int data = 0;
4882
4883 CFbcCommunication *fbcIns = GetSingletonFBC();
4884 if (fbcIns != NULL) {
4885 fbcIns->cfbc_Get_Dream_Panel_N310(COMM_DEV_SERIAL, &temp_value);
4886
4887 data = temp_value;
4888
4889 return data;
4890 }
4891
4892 return 0;
4893}
4894
4895int CTv::Tv_FactorySet_FBC_MULT_PQ_Status_N310 ( int value )
4896{
4897 int temp_value = value;
4898
4899 CFbcCommunication *fbcIns = GetSingletonFBC();
4900 if (fbcIns != NULL) {
4901 fbcIns->cfbc_Set_MULT_PQ_N310(COMM_DEV_SERIAL, temp_value);
4902 return 0;
4903 }
4904
4905 return -1;
4906}
4907
4908int CTv::Tv_FactoryGet_FBC_MULT_PQ_Status_N310 ( void )
4909{
4910 int temp_value = 0;
4911 int data = 0;
4912
4913 CFbcCommunication *fbcIns = GetSingletonFBC();
4914 if (fbcIns != NULL) {
4915 fbcIns->cfbc_Get_MULT_PQ_N310(COMM_DEV_SERIAL, &temp_value);
4916
4917 data = temp_value;
4918
4919 return data;
4920 }
4921
4922 return 0;
4923}
4924int CTv::Tv_FactorySet_FBC_MEMC_Status_N310 ( int value )
4925{
4926 int temp_value = value;
4927
4928 CFbcCommunication *fbcIns = GetSingletonFBC();
4929 if (fbcIns != NULL) {
4930 fbcIns->cfbc_Set_MEMC_N310(COMM_DEV_SERIAL, temp_value);
4931 return 0;
4932 }
4933
4934 return -1;
4935}
4936
4937int CTv::Tv_FactoryGet_FBC_MEMC_Status_N310 ( void )
4938{
4939 int temp_value = 0;
4940 int data = 0;
4941
4942 CFbcCommunication *fbcIns = GetSingletonFBC();
4943 if (fbcIns != NULL) {
4944 fbcIns->cfbc_Get_MEMC_N310(COMM_DEV_SERIAL, &temp_value);
4945
4946 data = temp_value;
4947
4948 return data;
4949 }
4950
4951 return 0;
4952}
4953
4954
4955
4956//audio
4957int CTv::SetAudioMuteForSystem(int muteOrUnmute)
4958{
4959 return mTvAudio.SetAudioMuteForSystem(muteOrUnmute);
4960}
4961
4962int CTv::GetAudioMuteForSystem()
4963{
4964 return mTvAudio.GetAudioMuteForSystem();
4965}
4966
4967int CTv::SetAudioAVOutMute(int muteStatus)
4968{
4969 return mTvAudio.SetAudioAVOutMute(muteStatus);
4970}
4971
4972int CTv::GetAudioAVOutMute()
4973{
4974 return mTvAudio.GetAudioAVOutMute();
4975}
4976
4977int CTv::SetAudioSPDIFMute(int muteStatus)
4978{
4979 return mTvAudio.SetAudioSPDIFMute(muteStatus);
4980}
4981
4982int CTv::GetAudioSPDIFMute()
4983{
4984 return mTvAudio.GetAudioSPDIFMute();
4985}
4986int CTv::SetAudioMasterVolume(int tmp_vol)
4987{
4988 return mTvAudio.SetAudioMasterVolume(tmp_vol);
4989}
4990
4991int CTv::GetAudioMasterVolume()
4992{
4993 return mTvAudio.GetAudioMasterVolume();
4994}
4995
4996int CTv::SaveCurAudioMasterVolume(int tmp_vol)
4997{
4998 return mTvAudio.SaveCurAudioMasterVolume(tmp_vol);
4999}
5000
5001int CTv::GetCurAudioMasterVolume()
5002{
5003 return mTvAudio.GetCurAudioMasterVolume();
5004}
5005
5006int CTv::SetAudioBalance(int tmp_val)
5007{
5008 return mTvAudio.SetAudioBalance(tmp_val);
5009}
5010
5011int CTv::GetAudioBalance()
5012{
5013 return mTvAudio.GetAudioBalance();
5014}
5015
5016int CTv::SaveCurAudioBalance(int tmp_val)
5017{
5018 return mTvAudio.SaveCurAudioBalance(tmp_val);
5019}
5020
5021int CTv::GetCurAudioBalance()
5022{
5023 return mTvAudio.GetCurAudioBalance();
5024}
5025
5026
5027int CTv::SetAudioSupperBassVolume(int tmp_vol)
5028{
5029 return mTvAudio.SetAudioSupperBassVolume(tmp_vol);
5030}
5031
5032int CTv::GetAudioSupperBassVolume()
5033{
5034 return mTvAudio.GetAudioSupperBassVolume();
5035}
5036
5037int CTv::SaveCurAudioSupperBassVolume(int tmp_vol)
5038{
5039 return mTvAudio.SaveCurAudioSupperBassVolume(tmp_vol);
5040}
5041
5042int CTv::GetCurAudioSupperBassVolume()
5043{
5044 return mTvAudio.GetCurAudioSupperBassVolume();
5045}
5046int CTv::SetAudioSupperBassSwitch(int tmp_val)
5047{
5048 return mTvAudio.SetAudioSupperBassSwitch(tmp_val);
5049}
5050
5051int CTv::GetAudioSupperBassSwitch()
5052{
5053 return mTvAudio.GetAudioSupperBassSwitch();
5054}
5055
5056int CTv::SaveCurAudioSupperBassSwitch(int tmp_val)
5057{
5058 return mTvAudio.SaveCurAudioSupperBassSwitch(tmp_val);
5059}
5060
5061int CTv::GetCurAudioSupperBassSwitch()
5062{
5063 return mTvAudio.GetCurAudioSupperBassSwitch();
5064}
5065
5066int CTv::SetAudioSRSSurround(int tmp_val)
5067{
5068 return mTvAudio.SetAudioSRSSurround(tmp_val);
5069}
5070
5071int CTv::GetAudioSRSSurround()
5072{
5073 return mTvAudio.GetAudioSRSSurround();
5074}
5075
5076int CTv::SaveCurAudioSrsSurround(int tmp_val)
5077{
5078 return mTvAudio.SaveCurAudioSrsSurround(tmp_val);
5079}
5080
5081int CTv::GetCurAudioSRSSurround()
5082{
5083 return mTvAudio.GetCurAudioSRSSurround();
5084}
5085
5086int CTv::SetAudioSrsDialogClarity(int tmp_val)
5087{
5088 return mTvAudio.SetAudioSrsDialogClarity(tmp_val);
5089}
5090
5091int CTv::GetAudioSrsDialogClarity()
5092{
5093 return mTvAudio.GetAudioSrsDialogClarity();
5094}
5095
5096int CTv::SaveCurAudioSrsDialogClarity(int tmp_val)
5097{
5098 return mTvAudio.SaveCurAudioSrsDialogClarity(tmp_val);
5099}
5100
5101int CTv::GetCurAudioSrsDialogClarity()
5102{
5103 return mTvAudio.GetCurAudioSrsDialogClarity();
5104}
5105
5106int CTv::SetAudioSrsTruBass(int tmp_val)
5107{
5108 return mTvAudio.SetAudioSrsTruBass(tmp_val);
5109}
5110
5111int CTv::GetAudioSrsTruBass()
5112{
5113 return mTvAudio.GetAudioSrsTruBass();
5114}
5115
5116int CTv::SaveCurAudioSrsTruBass(int tmp_val)
5117{
5118 return mTvAudio.SaveCurAudioSrsTruBass(tmp_val);
5119}
5120
5121int CTv::GetCurAudioSrsTruBass()
5122{
5123 return mTvAudio.GetCurAudioSrsTruBass();
5124}
5125
5126int CTv::SetAudioBassVolume(int tmp_vol)
5127{
5128 return mTvAudio.SetAudioBassVolume(tmp_vol);
5129}
5130
5131int CTv::GetAudioBassVolume()
5132{
5133 return mTvAudio.GetAudioBassVolume();
5134}
5135
5136int CTv::SaveCurAudioBassVolume(int tmp_vol)
5137{
5138 return mTvAudio.SaveCurAudioBassVolume(tmp_vol);
5139}
5140
5141int CTv::GetCurAudioBassVolume()
5142{
5143 return mTvAudio.GetCurAudioBassVolume();
5144}
5145
5146int CTv::SetAudioTrebleVolume(int tmp_vol)
5147{
5148 return mTvAudio.SetAudioTrebleVolume(tmp_vol);
5149}
5150
5151int CTv::GetAudioTrebleVolume()
5152{
5153 return mTvAudio.GetAudioTrebleVolume();
5154}
5155
5156int CTv::SaveCurAudioTrebleVolume(int tmp_vol)
5157{
5158 return mTvAudio.SaveCurAudioTrebleVolume(tmp_vol);
5159}
5160
5161int CTv::GetCurAudioTrebleVolume()
5162{
5163 return mTvAudio.GetCurAudioTrebleVolume();
5164}
5165
5166int CTv::SetAudioSoundMode(int tmp_val)
5167{
5168 return mTvAudio.SetAudioSoundMode(tmp_val);
5169}
5170
5171int CTv::GetAudioSoundMode()
5172{
5173 return mTvAudio.GetAudioSoundMode();
5174}
5175
5176int CTv::SaveCurAudioSoundMode(int tmp_val)
5177{
5178 return mTvAudio.SaveCurAudioSoundMode(tmp_val);
5179}
5180
5181int CTv::GetCurAudioSoundMode()
5182{
5183 return mTvAudio.GetCurAudioSoundMode();
5184}
5185
5186int CTv::SetAudioWallEffect(int tmp_val)
5187{
5188 return mTvAudio.SetAudioWallEffect(tmp_val);
5189}
5190
5191int CTv::GetAudioWallEffect()
5192{
5193 return mTvAudio.GetAudioWallEffect();
5194}
5195
5196int CTv::SaveCurAudioWallEffect(int tmp_val)
5197{
5198 return mTvAudio.SaveCurAudioWallEffect(tmp_val);
5199}
5200
5201int CTv::GetCurAudioWallEffect()
5202{
5203 return mTvAudio.GetCurAudioWallEffect();
5204}
5205
5206
5207int CTv::SetAudioEQMode(int tmp_val)
5208{
5209 return mTvAudio.SetAudioEQMode(tmp_val);
5210}
5211
5212int CTv::GetAudioEQMode()
5213{
5214 return mTvAudio.GetAudioEQMode();
5215}
5216
5217int CTv::SaveCurAudioEQMode(int tmp_val)
5218{
5219 return mTvAudio.SaveCurAudioEQMode(tmp_val);
5220}
5221
5222int CTv::GetCurAudioEQMode()
5223{
5224 return mTvAudio.GetCurAudioEQMode();
5225}
5226
5227int CTv::GetAudioEQRange(int range_buf[])
5228{
5229 return mTvAudio.GetAudioEQRange(range_buf);
5230}
5231
5232int CTv::SetAudioEQGain(int gain_buf[])
5233{
5234 return mTvAudio.SetAudioEQGain(gain_buf);
5235}
5236
5237int CTv::GetAudioEQGain(int gain_buf[])
5238{
5239 return mTvAudio.GetAudioEQGain(gain_buf);
5240}
5241
5242int CTv::SaveCurAudioEQGain(int gain_buf[])
5243{
5244 return mTvAudio.SaveCurAudioEQGain(gain_buf);
5245}
5246
5247int CTv::GetCurAudioEQGain(int gain_buf[])
5248{
5249 return mTvAudio.GetCurAudioEQGain(gain_buf);
5250}
5251
5252int CTv::GetAudioEQBandCount()
5253{
5254 return mTvAudio.GetAudioEQBandCount();
5255}
5256
5257
5258
5259int CTv::SetAudioEQSwitch(int switch_val)
5260{
5261 return mTvAudio.SetAudioEQSwitch(switch_val);
5262}
5263
5264int CTv::SetAudioSPDIFSwitch(int tmp_val)
5265{
5266 return mTvAudio.SetAudioSPDIFSwitch(tmp_val);
5267}
5268
5269/*showboz public int GetAudioSPDIFSwitch() {
5270 mTvAudio.GetAudioSPDIFSwitch();
5271}*/
5272
5273int CTv::amAudioSetDoubleOutputSwitch(int en_val)
5274{
5275 return mTvAudio.amAudioSetDoubleOutputSwitch(en_val);
5276}
5277int CTv::UsbAudioOuputModuleSwitch(int sw)
5278{
5279 return mTvAudio.UsbAudioOuputModuleSwitch(sw);
5280}
5281
5282int CTv::GetAmAudioSetDoubleOutputSwitch()
5283{
5284 return mTvAudio.GetAmAudioSetDoubleOutputSwitch();
5285}
5286
5287int CTv::GetCurUsbAudioOuputModuleSwitch()
5288{
5289 return mTvAudio.GetCurUsbAudioOuputModuleSwitch();
5290}
5291
5292int CTv::SaveCurAudioSPDIFSwitch(int tmp_val)
5293{
5294 return mTvAudio.SaveCurAudioSPDIFSwitch(tmp_val);
5295}
5296
5297int CTv::GetCurAudioSPDIFSwitch()
5298{
5299 return mTvAudio.GetCurAudioSPDIFSwitch();
5300}
5301int CTv::SetAudioSPDIFMode(int tmp_val)
5302{
5303 return mTvAudio.SetAudioSPDIFMode(tmp_val);
5304}
5305
5306/* public int GetAudioSPDIFMode() {
5307mTvAudio.GetAudioSPDIFMode();
5308showboz */
5309
5310
5311int CTv::SaveCurAudioSPDIFMode(int tmp_val)
5312{
5313 return mTvAudio.SaveCurAudioSPDIFMode(tmp_val);
5314}
5315
5316int CTv::GetCurAudioSPDIFMode()
5317{
5318 return mTvAudio.GetCurAudioSPDIFMode();
5319}
5320
5321int CTv::OpenAmAudio(unsigned int sr, int output_device)
5322{
5323 return mTvAudio.OpenAmAudio(sr, output_device);
5324}
5325
5326int CTv::CloseAmAudio(void)
5327{
5328 return mTvAudio.CloseAmAudio();
5329}
5330
5331int CTv::SetAmAudioInputSr(unsigned int sr, int output_device)
5332{
5333 return mTvAudio.SetAmAudioInputSr(sr, output_device);
5334}
5335
5336int CTv::SetAmAudioOutputMode(int mode)
5337{
5338 return mTvAudio.SetAmAudioOutputMode(mode);
5339}
5340
5341int CTv::SetAmAudioMusicGain(int gain)
5342{
5343 return mTvAudio.SetAmAudioMusicGain(gain);
5344}
5345
5346int CTv::SetAmAudioLeftGain(int gain)
5347{
5348 return mTvAudio.SetAmAudioLeftGain(gain);
5349}
5350
5351
5352int CTv::SetAmAudioRightGain(int gain)
5353{
5354 return mTvAudio.SetAmAudioRightGain(gain);
5355}
5356
5357int CTv::AudioLineInSelectChannel(int audio_channel)
5358{
5359 return mTvAudio.AudioLineInSelectChannel(audio_channel);
5360}
5361
5362int CTv::SetKalaokIO(int level)
5363{
5364 return mTvAudio.SetKalaokIO(level);
5365}
5366int CTv::AudioSetAudioInSource(int audio_src_in_type)
5367{
5368 return mTvAudio.AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_LINEIN);
5369}
5370
5371int CTv::AudioSetLineInCaptureVolume(int l_vol, int r_vol)
5372{
5373 return mTvAudio.AudioSetLineInCaptureVolume(l_vol, r_vol);
5374}
5375
5376int CTv::AudioHandleHeadsetPlugIn()
5377{
5378 return mTvAudio.AudioHandleHeadsetPlugIn();
5379}
5380
5381int CTv::AudioHandleHeadsetPullOut()
5382{
5383 return mTvAudio.AudioHandleHeadsetPullOut();
5384}
5385