summaryrefslogtreecommitdiff
path: root/tvapi/libtv/tv/CTv.cpp (plain)
blob: a8574bd00fbb19d6ff69fdfb71ba0974924f7031
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
63using namespace android;
64
65// Called each time a message is logged.
66static void sqliteLogCallback(void *data, int iErrCode, const char *zMsg)
67{
68 LOGD( "showbo sqlite (%d) %s\n", iErrCode, zMsg);
69}
70
71
72
73CTv::CTv() : mSigDetectThread ( &mTvin ), mSourceConnectDetectThread(&mTvin), mHDMIRxCEC ( &mTvin ), mTvScanner ( &mTvin ), mTvMsgQueue(this), mAutoBackLight( &mVpp, &mTvin )
74{
75 //mpClient = pClient;
76 //copy file to param
77 if ( Tv_Utils_IsFileExist ( TV_CONFIG_FILE_SYSTEM_PATH ) == 0 ) {
78 if ( Tv_Utils_IsFileExist ( TV_CONFIG_FILE_PARAM_PATH ) != 0 ) {
79 CFile file ( TV_CONFIG_FILE_SYSTEM_PATH );
80
81 if ( file.copyTo ( TV_CONFIG_FILE_PARAM_PATH ) != 0 ) {
82 LOGE ( "%s, copy file = %s , error", __FUNCTION__, TV_CONFIG_FILE_PARAM_PATH );
83 }
84 }
85 }
86
87 if ( Tv_Utils_IsFileExist ( TV_CHANNEL_LIST_SYSTEM_PATH ) == 0 ) {
88 if ( Tv_Utils_IsFileExist ( TV_CHANNEL_LIST_PARAM_PATH ) != 0 ) {
89 CFile file ( TV_CHANNEL_LIST_SYSTEM_PATH );
90
91 if ( file.copyTo ( TV_CHANNEL_LIST_PARAM_PATH ) != 0 ) {
92 LOGE ( "%s, copy file = %s , error", __FUNCTION__, TV_CHANNEL_LIST_PARAM_PATH );
93 }
94 }
95 }
96
97 //ssm
98 if ( Tv_Utils_IsFileExist ( TV_SSM_DATA_SYSTEM_PATH ) == 0 ) {
99 if ( Tv_Utils_IsFileExist ( TV_SSM_DATA_PARAM_PATH ) != 0 ) {
100 CFile file ( TV_SSM_DATA_SYSTEM_PATH );
101
102 if ( file.copyTo ( TV_SSM_DATA_PARAM_PATH ) != 0 ) {
103 LOGE ( "%s, copy file = %s , error", __FUNCTION__, TV_SSM_DATA_PARAM_PATH );
104 }
105 }
106 }
107
108 AM_EVT_Init();
109 mTvEpg.setObserver ( &mTvMsgQueue );
110 mpObserver = NULL;
111 audio_sr = 0;
112 mIsFbc = false;
113 dtv_auto_3d_flag = 0;
114 m_autoset_displayfreq = false;
115 m_cur_set_info_fmt = TVIN_SIG_FMT_CVBS_PAL_I;
116
117 tv_config_load ( TV_CONFIG_FILE_PATH );
118 sqlite3_config (SQLITE_CONFIG_SERIALIZED);
119 sqlite3_config(SQLITE_CONFIG_LOG, &sqliteLogCallback, (void *)1);
120 sqlite3_soft_heap_limit(8 * 1024 * 1024);
121 // Initialize SQLite.
122 sqlite3_initialize();
123 CTvDatabase::GetTvDb()->InitTvDb ( TV_DB_PATH );
124 if ( CTvDimension::isDimensionTblExist() == false ) {
125 CTvDimension::builtinAtscDimensions();
126 }
127
128 CTvSettingLoad();
129
130 mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL;
131
132 m_sig_stable_nums = 0;
133 m_is_set_hdmi_edid = false;
134 m_cur_playing_prog_id = -1;
135
136 mSigDetectThread.setObserver ( this );
137 mSourceConnectDetectThread.setObserver ( this );
138 mHDMIRxCEC.setObserver(this);
139 mFrontDev.setObserver ( &mTvMsgQueue );
140 mpUpgradeFBC = NULL;
141 if (GetPlatformHaveFBCFlag() == 1) {
142 mIsFbc = true;
143
144 mpUpgradeFBC = new CUpgradeFBC();
145 mpUpgradeFBC->setObserver(this);
146 }
147 mSerialA.setObserver(this);
148 mSerialB.setObserver(this);
149 mSerialC.setObserver(this);
150 mAv.setObserver(&mTvMsgQueue);
151 mTvAction = mTvAction & TV_ACTION_NULL;
152 mTvStatus = TV_INIT_ED;
153
154 print_version_info();
155};
156
157CTv::~CTv()
158{
159 int iRet;
160 mpObserver = NULL;
161 CTvSettingunLoad();
162 CTvDatabase::deleteTvDb();
163 tv_config_unload();
164 mAv.Close();
165 mTvStatus = TV_INIT_ED;
166 mFrontDev.Close();
167
168 if (mpUpgradeFBC != NULL) {
169 delete mpUpgradeFBC;
170 mpUpgradeFBC = NULL;
171 }
172}
173
174void CTv::onEvent ( const CTvScanner::ScannerEvent &ev )
175{
176 LOGD ( "%s, CTv::onEvent lockStatus = %d type = %d\n", __FUNCTION__, ev.mLockedStatus, ev.mType );
177
178 if ( mDtvScanRunningStatus == DTV_SCAN_RUNNING_ANALYZE_CHANNEL ) {
179 if ( ev.mType == CTvScanner::ScannerEvent::EVENT_SCAN_END ) {
180 CMessage msg;
181 msg.mType = CTvMsgQueue::TV_MSG_STOP_ANALYZE_TS;
182 msg.mpData = this;
183 mTvMsgQueue.sendMsg ( msg );
184 } else if ( ev.mType == CTvScanner::ScannerEvent::EVENT_STORE_END ) {
185 CTvEpg::EpgEvent epgev;
186 epgev.type = CTvEpg::EpgEvent::EVENT_CHANNEL_UPDATE_END;
187 mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL;
188 sendTvEvent ( epgev );
189 }
190 } else {
191 sendTvEvent ( ev );
192 }
193}
194
195void CTv::onEvent ( const CFrontEnd::FEEvent &ev )
196{
197 LOGD ( "%s, FE event type = %d tvaction=%x", __FUNCTION__, ev.mCurSigStaus, mTvAction);
198 if (mTvAction & TV_ACTION_SCANNING) return;
199
200 //前端事件响应处理
201 if ( ev.mCurSigStaus == CFrontEnd::FEEvent::EVENT_FE_HAS_SIG ) { //作为信号稳定
202 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
203 Vpp_SetDisplayMode ( mVpp.Tv_GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt);
204 if ( m_win_mode == PREVIEW_WONDOW ) {
205 mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2);
206 mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_FULL_STRETCH );
207 }
208
209 if ( m_autoset_displayfreq) {
210 mTvin.VDIN_SetDisplayVFreq ( 50, mAv.getVideoDisplayResolution() , mIsFbc);
211 }
212 TvEvent::SignalInfoEvent ev;
213 ev.mStatus = TVIN_SIG_STATUS_STABLE;
214 ev.mTrans_fmt = TVIN_TFMT_2D;
215 ev.mFmt = TVIN_SIG_FMT_NULL;
216 ev.mReserved = 0;
217 sendTvEvent ( ev );
218 mAv.EnableVideoAuto();
219 mTvAudio.SetAudioMuteForTv ( CC_AUDIO_UNMUTE );
220 }
221 } else if ( ev.mCurSigStaus == CFrontEnd::FEEvent::EVENT_FE_NO_SIG ) { //作为信号消失
222 if (/*m_source_input == SOURCE_TV || */m_source_input == SOURCE_DTV && (mTvAction & TV_ACTION_PLAYING)) { //just playing
223 mAv.DisableVideoWithBlueColor();
224 //
225 TvEvent::SignalInfoEvent ev;
226 ev.mStatus = TVIN_SIG_STATUS_NOSIG;
227 ev.mTrans_fmt = TVIN_TFMT_2D;
228 ev.mFmt = TVIN_SIG_FMT_NULL;
229 ev.mReserved = 0;
230 sendTvEvent ( ev );
231 }
232 }
233
234}
235
236void CTv::onEvent ( const CTvEpg::EpgEvent &ev )
237{
238 switch ( ev.type ) {
239 case CTvEpg::EpgEvent::EVENT_TDT_END:
240 LOGD ( "%s, CTv::onEvent epg time = %ld", __FUNCTION__, ev.time );
241 mTvTime.setTime ( ev.time );
242 break;
243
244 case CTvEpg::EpgEvent::EVENT_CHANNEL_UPDATE: {
245 LOGD ( "%s, CTv:: onEvent channel update", __FUNCTION__ );
246 CMessage msg;
247 msg.mType = CTvMsgQueue::TV_MSG_START_ANALYZE_TS;
248 msg.mpData = this;
249 mCurAnalyzeTsChannelID = ev.channelID;
250 mTvMsgQueue.sendMsg ( msg );
251 break;
252 }
253
254 default:
255 break;
256 }
257
258 sendTvEvent ( ev );
259}
260
261
262void CTv::onEvent(const CAv::AVEvent &ev)
263{
264 LOGD("AVEvent = %d", ev.type);
265 switch ( ev.type ) {
266 case CAv::AVEvent::EVENT_AV_STOP: {
267 break;
268 }
269 case CAv::AVEvent::EVENT_AV_RESUEM: {
270 mAv.EnableVideoAuto();
271 TvEvent::AVPlaybackEvent AvPlayBackEvt;
272 AvPlayBackEvt.mMsgType = TvEvent::AVPlaybackEvent::EVENT_AV_PLAYBACK_RESUME;
273 AvPlayBackEvt.mProgramId = ( int ) ev.param;
274 sendTvEvent(AvPlayBackEvt );
275 break;
276 }
277 case CAv::AVEvent::EVENT_AV_SCAMBLED: {
278 mAv.DisableVideoWithBlueColor();
279 TvEvent::AVPlaybackEvent AvPlayBackEvt;
280 AvPlayBackEvt.mMsgType = TvEvent::AVPlaybackEvent::EVENT_AV_SCAMBLED;
281 AvPlayBackEvt.mProgramId = ( int ) ev.param;
282 sendTvEvent(AvPlayBackEvt );
283 break;
284 }
285 case CAv::AVEvent::EVENT_AV_UNSUPPORT: {
286 LOGD("To AVS or AVS+ format");//just avs format, not unsupport, and avs avs+
287 break;
288 }
289 default:
290 break;
291 }
292}
293
294CTv::CTvMsgQueue::CTvMsgQueue(CTv *tv)
295{
296 mpTv = tv;
297}
298
299CTv::CTvMsgQueue::~CTvMsgQueue()
300{
301}
302
303void CTv::CTvMsgQueue::handleMessage ( CMessage &msg )
304{
305 LOGD ( "%s, CTv::CTvMsgQueue::handleMessage type = %d", __FUNCTION__, msg.mType );
306
307 switch ( msg.mType ) {
308 case TV_MSG_COMMON:
309 break;
310
311 case TV_MSG_STOP_ANALYZE_TS: {
312 //mpTv->Tv_Stop_Analyze_Ts();
313 break;
314 }
315
316 case TV_MSG_START_ANALYZE_TS: {
317 //mpTv->Tv_Start_Analyze_Ts ( pTv->mCurAnalyzeTsChannelID );
318 break;
319 }
320
321 case TV_MSG_CHECK_FE_DELAY: {
322 mpTv->mFrontDev.checkStatusOnce();
323 break;
324 }
325 case TV_MSG_AV_EVENT: {
326 mpTv->onEvent(*((CAv::AVEvent *)(msg.mpPara)));
327 break;
328 }
329 case TV_MSG_FE_EVENT: {
330 mpTv->onEvent(*((CFrontEnd::FEEvent *)(msg.mpPara)));
331 break;
332 }
333 case TV_MSG_SCAN_EVENT: {
334 mpTv->onEvent(*((CTvScanner::ScannerEvent *)(msg.mpPara)));
335 break;
336 }
337 case TV_MSG_EPG_EVENT: {
338 mpTv->onEvent(*((CTvEpg::EpgEvent *)(msg.mpPara)));
339 break;
340 }
341
342 default:
343 break;
344 }
345}
346
347
348void CTv::CTvMsgQueue::onEvent ( const CTvScanner::ScannerEvent &ev )
349{
350 CMessage msg;
351 msg.mDelayMs = 0;
352 msg.mType = CTvMsgQueue::TV_MSG_SCAN_EVENT;
353 memcpy(msg.mpPara, &ev, sizeof(ev));
354 this->sendMsg ( msg );
355}
356
357void CTv::CTvMsgQueue::onEvent ( const CFrontEnd::FEEvent &ev )
358{
359 CMessage msg;
360 msg.mDelayMs = 0;
361 msg.mType = CTvMsgQueue::TV_MSG_FE_EVENT;
362 memcpy(msg.mpPara, &ev, sizeof(ev));
363 this->sendMsg ( msg );
364}
365
366void CTv::CTvMsgQueue::onEvent ( const CTvEpg::EpgEvent &ev )
367{
368 CMessage msg;
369 msg.mDelayMs = 0;
370 msg.mType = CTvMsgQueue::TV_MSG_EPG_EVENT;
371 memcpy(msg.mpPara, &ev, sizeof(ev));
372 this->sendMsg ( msg );
373}
374
375
376void CTv::CTvMsgQueue::onEvent(const CAv::AVEvent &ev)
377{
378 CMessage msg;
379 msg.mDelayMs = 0;
380 msg.mType = CTvMsgQueue::TV_MSG_AV_EVENT;
381 memcpy(msg.mpPara, &ev, sizeof(ev));
382 this->sendMsg ( msg );
383}
384
385int CTv::setTvObserver ( TvIObserver *ob )
386{
387 mpObserver = ob;
388 return 0;
389}
390
391void CTv::sendTvEvent ( const CTvEv &ev )
392{
393 //AutoMutex lock(mLock);
394 /* send sigstate to AutoBackLight */
395 if (ev.getEvType() == CTvEv::TV_EVENT_SIGLE_DETECT) {
396 TvEvent::SignalInfoEvent *pEv = (TvEvent::SignalInfoEvent *)(&ev);
397 if (pEv->mStatus == TVIN_SIG_STATUS_STABLE) {
398 mAutoBackLight.updateSigState(mAutoBackLight.SIG_STATE_STABLE);
399 } else {
400 mAutoBackLight.updateSigState(mAutoBackLight.SIG_STATE_NOSIG);
401 }
402 }
403
404 LOGD ( "%s, tvaction=%x", __FUNCTION__, mTvAction);
405 if ((mTvAction & TV_ACTION_SCANNING) && (ev.getEvType() == CTvEv::TV_EVENT_SIGLE_DETECT)) {
406 LOGD("%s, when scanning, not send sig detect event", __FUNCTION__);
407 return;
408 }
409 if ( mpObserver != NULL ) {
410 mpObserver->onTvEvent ( ev );
411 }
412
413 return;
414}
415
416int CTv::ClearAnalogFrontEnd()
417{
418 return mFrontDev.ClearAnalogFrontEnd ();
419}
420
421int CTv::dtvAutoScan()
422{
423 AutoMutex lock ( mLock );
424 mTvAction = mTvAction | TV_ACTION_SCANNING;
425 mTvEpg.leaveChannel();
426 mAv.StopTS ();
427 mAv.DisableVideoWithBlueColor();
428 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_DTV );
429 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_RADIO );
430 CTvEvent::CleanAllEvent();
431 mTvScanner.setObserver ( &mTvMsgQueue );
432 mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL;
433 mFrontDev.Open(FE_DTMB);
434 mTvScanner.autoDtmbScan();//dtmb
435 return 0;
436}
437
438int CTv::dtvCleanProgramByFreq ( int freq )
439{
440 int iOutRet = 0;
441 CTvChannel channel;
442 iOutRet = CTvChannel::SelectByFreq ( freq, channel );
443 if ( -1 == iOutRet ) {
444 LOGD ( "%s, Warnning: Current Freq not have program info in the ts_table\n", __FUNCTION__ );
445 }
446
447 iOutRet == CTvProgram::deleteChannelsProgram ( channel );
448 return iOutRet;
449}
450
451int CTv::dtvManualScan (int beginFreq, int endFreq, int modulation)
452{
453 AutoMutex lock ( mLock );
454 mTvAction = mTvAction | TV_ACTION_SCANNING;
455 mTvEpg.leaveChannel();
456 mAv.StopTS ();
457 mAv.DisableVideoWithBlueColor();
458 CTvChannel::DeleteBetweenFreq(beginFreq, endFreq);
459 mTvScanner.setObserver ( &mTvMsgQueue );
460 mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL;
461 mFrontDev.Open(FE_DTMB);
462 int iOutRet = mTvScanner.manualDtmbScan (beginFreq, endFreq, modulation); //dtmb
463 return iOutRet;
464}
465
466int CTv::dtvAutoScanAtscLock(int attenna, int videoStd, int audioStd)
467{
468 //showboz
469 int minScanFreq, maxScanFreq, vStd, aStd;
470 vStd = CC_ATV_VIDEO_STD_PAL;
471 aStd = CC_ATV_AUDIO_STD_DK;
472 v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor(vStd, aStd);
473
474 AutoMutex lock ( mLock );
475 mTvAction = mTvAction | TV_ACTION_SCANNING;
476 mTvEpg.leaveChannel();
477 mAv.StopTS ();
478 mAv.DisableVideoWithBlueColor();
479 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_DTV );
480 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_RADIO );
481 CTvEvent::CleanAllEvent();
482 mTvScanner.setObserver ( &mTvMsgQueue );
483 mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL;
484 mFrontDev.Open(FE_ATSC);
485 mTvScanner.autoAtscScan(CTvScanner::AM_ATSC_ATTENNA_TYPE_AIR, stdAndColor);//dtmb
486 return 0;
487}
488
489//searchType 0:not 256 1:is 256 Program
490int CTv::atvAutoScan(int videoStd, int audioStd, int searchType)
491{
492 int minScanFreq, maxScanFreq, vStd, aStd;
493 AutoMutex lock ( mLock );
494 mAv.DisableVideoWithBlueColor();
495 mTvAction = mTvAction | TV_ACTION_SCANNING;
496 mTvScanner.setObserver ( &mTvMsgQueue );
497 mTvAudio.SetAudioMuteForTv ( CC_AUDIO_MUTE );
498 getATVMinMaxFreq (&minScanFreq, &maxScanFreq );
499 if ( minScanFreq == 0 || maxScanFreq == 0 || minScanFreq > maxScanFreq ) {
500 LOGE ( "%s, auto scan freq set is error min=%d, max=%d", __FUNCTION__, minScanFreq, maxScanFreq );
501 return -1;
502 }
503 //if set std null AUTO, use default PAL/DK
504 //if(videoStd == CC_ATV_VIDEO_STD_AUTO) {
505 // vStd = CC_ATV_VIDEO_STD_PAL;
506 // aStd = CC_ATV_AUDIO_STD_DK;
507 //} else {
508 vStd = videoStd;
509 aStd = audioStd;
510 //}
511 tvin_port_t source_port = mTvin.Tvin_GetSourcePortBySourceInput(SOURCE_TV);
512 mTvin.VDIN_OpenPort ( source_port );
513 LOGD("%s, atv auto scan vstd=%d, astd=%d ", __FUNCTION__, vStd, aStd);
514 v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor(vStd, aStd);
515
516 int fmt = CFrontEnd::stdEnumToCvbsFmt (vStd, aStd);
517 mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt );
518 m_cur_set_info_fmt = ( tvin_sig_fmt_t )fmt;
519
520 if (searchType == 0) {
521 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_ATV );
522 } else if (searchType == 1) { //type for skyworth, and insert 256 prog, and just update ts table
523 }
524 minScanFreq = mFrontDev.formatATVFreq ( minScanFreq );
525 maxScanFreq = mFrontDev.formatATVFreq ( maxScanFreq );
526 LOGD("%s, atv auto scan vstd=%d, astd=%d stdandcolor=%lld", __FUNCTION__, vStd, aStd, stdAndColor);
527 mSigDetectThread.setVdinNoSigCheckKeepTimes(1000, false);
528 mFrontDev.Open(FE_ANALOG);
529 mTvScanner.autoAtvScan ( minScanFreq, maxScanFreq, stdAndColor, searchType );
530 return 0;
531}
532
533int CTv::clearAllProgram(int arg0)
534{
535 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_ATV );
536 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_TV );
537 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_DTV );
538 CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_RADIO);
539 return 0;
540}
541
542int CTv::atvMunualScan ( int startFreq, int endFreq, int videoStd, int audioStd, int store_Type , int channel_num )
543{
544 int minScanFreq, maxScanFreq, vStd, aStd;
545
546 minScanFreq = mFrontDev.formatATVFreq ( startFreq );
547 maxScanFreq = mFrontDev.formatATVFreq ( endFreq );
548 if ( minScanFreq == 0 || maxScanFreq == 0 ) {
549 LOGE ( "%s, munual scan freq set is error min=%d, max=%d", __FUNCTION__, minScanFreq, maxScanFreq );
550 return -1;
551 }
552
553 //if set std null AUTO, use default PAL/DK
554 //if(videoStd == CC_ATV_VIDEO_STD_AUTO) {
555 // vStd = CC_ATV_VIDEO_STD_PAL;
556 // aStd = CC_ATV_AUDIO_STD_DK;
557 // } else {
558 vStd = videoStd;
559 aStd = audioStd;
560 // }
561
562 AutoMutex lock ( mLock );
563 mAv.DisableVideoWithBlueColor();
564 mTvAction = mTvAction | TV_ACTION_SCANNING;
565 mTvScanner.setObserver ( &mTvMsgQueue );
566
567 mTvAudio.SetAudioMuteForTv ( CC_AUDIO_MUTE );
568 v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor(vStd, aStd);
569
570
571 tvin_port_t source_port = mTvin.Tvin_GetSourcePortBySourceInput(SOURCE_TV);
572 mTvin.VDIN_OpenPort ( source_port );
573
574 int fmt = CFrontEnd::stdEnumToCvbsFmt (vStd, aStd);
575 mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt );
576 m_cur_set_info_fmt = ( tvin_sig_fmt_t )fmt;
577 LOGD("%s, atv manual scan vstd=%d, astd=%d stdandcolor=%lld", __FUNCTION__, videoStd, audioStd, stdAndColor);
578 mFrontDev.Open(FE_ANALOG);
579 return mTvScanner.ATVManualScan ( minScanFreq, maxScanFreq, stdAndColor, store_Type, channel_num);
580}
581
582int CTv::getVideoFormatInfo ( int *pWidth, int *pHeight, int *pFPS, int *pInterlace )
583{
584 int iOutRet = -1;
585 AM_AV_VideoStatus_t video_status;
586
587 do {
588 if ( NULL == pWidth || NULL == pHeight || NULL == pFPS || NULL == pInterlace ) {
589 break;
590 }
591
592 iOutRet = mAv.GetVideoStatus (&video_status );
593
594 if ( AM_SUCCESS != iOutRet ) {
595 LOGD ( "%s, ERROR: Cann't Get video format info\n", __FUNCTION__);
596 break;
597 }
598
599 *pWidth = video_status.src_w;
600 *pHeight = video_status.src_h;
601 *pFPS = video_status.fps;
602 *pInterlace = video_status.interlaced;
603 //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);
604 } while ( false );
605
606 return iOutRet;
607
608}
609
610int CTv::stopScanLock()
611{
612 AutoMutex lock ( mLock );
613 return stopScan();
614}
615
616int CTv::stopScan()
617{
618 if (!(mTvAction & TV_ACTION_SCANNING)) {
619 LOGD("%s, tv not scanning ,return\n", __FUNCTION__);
620 return 0;
621 }
622 mSigDetectThread.requestAndWaitPauseDetect();
623 mTvEpg.leaveChannel();
624 mTvScanner.stopScan();
625 mFrontDev.Close();
626 mTvAction = mTvAction & ~TV_ACTION_SCANNING;
627 return 0;
628}
629
630int CTv::playProgramLock ( int progId )
631{
632 AutoMutex lock ( mLock );
633 CTvProgram prog;
634 int ret = CTvProgram::selectByID ( progId, prog );
635
636 if ( ret != 0 ) {
637 return -1;
638 }
639 int type = prog.getProgType();
640 LOGD ( "%s, blackout = %dprog type = %d id = %d name = %s\n", __FUNCTION__, m_blackout_enable, type, progId, prog.getName().string() );
641 if (m_blackout_enable == 1) {
642 mAv.EnableVideoBlackout();
643 } else if (m_blackout_enable == 0) {
644 mAv.DisableVideoBlackout();
645 }
646
647 mTvAction = mTvAction | TV_ACTION_PLAYING;
648 m_cur_playing_prog_id = progId;
649 mFrontDev.Open(FE_ANALOG);
650 if ( m_source_input == SOURCE_TV && type == CTvProgram::TYPE_ATV ) {
651 playAtvProgram ( progId );
652 } else if ( m_source_input == SOURCE_DTV && ( type == CTvProgram::TYPE_DTV || type == CTvProgram::TYPE_RADIO ) ) {
653 playDtmbProgram ( progId );
654 } else {
655 LOGD ( "%s, source(%d) != type(%d),not play\n", __FUNCTION__, m_source_input, type );
656 }
657 //just for ui,left/right/stereo
658 setAudioChannel((int)AM_AOUT_OUTPUT_STEREO);
659 return 0;
660}
661
662int CTv::playDvbcProgram ( int progId )
663{
664 LOGD ( "%s, progId = %d\n", __FUNCTION__, progId );
665
666 CTvProgram prog;
667 int ret = CTvProgram::selectByID ( progId, prog );
668
669 if ( ret != 0 ) {
670 return -1;
671 }
672
673 LOGD ( "%s, prog name = %s\n", __FUNCTION__, prog.getName().string() );
674 CTvChannel channel;
675 prog.getChannel ( channel );
676
677 mFrontDev.setPara ( channel.getMode(), channel.getFrequency(), channel.getSymbolRate(), channel.getModulation() );
678
679 int vpid = 0x1fff, apid = 0x1fff, vfmt = -1, afmt = -1;
680
681 CTvProgram::Video *pV = prog.getVideo();
682 CTvProgram::Audio *pA;
683
684 if ( pV != NULL ) {
685 vpid = pV->getPID();
686 vfmt = pV->getFormat();
687 }
688
689 int aindex = prog.getCurrentAudio ( String8 ( "eng" ) );
690
691 if ( aindex >= 0 ) {
692 pA = prog.getAudio ( aindex );
693
694 if ( pA != NULL ) {
695 apid = pA->getPID();
696 afmt = pA->getFormat();
697 }
698 }
699 mTvEpg.leaveProgram();
700 mTvEpg.leaveChannel();
701 startPlayTv ( SOURCE_DTV, vpid, apid, vfmt, afmt );
702
703 mTvEpg.enterChannel ( channel.getID() );
704 mTvEpg.enterProgram ( prog.getID() );
705 return 0;
706}
707
708int CTv::getAudioTrackNum ( int progId )
709{
710 int iRet, iOutCnt = 0;
711 CTvProgram prog;
712
713 do {
714 if ( 0 > progId ) {
715 break;
716 }
717
718 iRet = CTvProgram::selectByID ( progId, prog );
719
720 if ( 0 != iRet ) {
721 break;
722 }
723
724 iOutCnt = prog.getAudioTrackSize();
725
726 } while ( false );
727
728 return iOutCnt;
729}
730
731int CTv::getAudioInfoByIndex ( int progId, int idx, int *pAFmt, String8 &lang )
732{
733 int iRet, iOutRet = -1;
734 CTvProgram prog;
735 CTvProgram::Audio *pA = NULL;
736
737 do {
738 if ( NULL == pAFmt || idx < 0 ) {
739 break;
740 }
741
742 iRet = CTvProgram::selectByID ( progId, prog );
743
744 if ( 0 != iRet ) {
745 break;
746 }
747
748 if ( idx >= prog.getAudioTrackSize() ) {
749 break;
750 }
751
752 pA = prog.getAudio ( idx );
753
754 if ( NULL == pA ) {
755 break;
756 }
757
758 *pAFmt = pA->getFormat();
759 lang = pA->getLang();
760 } while ( false );
761
762 return iOutRet;
763}
764
765int CTv::switchAudioTrack ( int progId, int idx )
766{
767 int iOutRet = 0;
768 CTvProgram prog;
769 CTvProgram::Audio *pAudio = NULL;
770 int aPid = -1;
771 int aFmt = -1;
772
773 do {
774 if ( idx < 0 ) {
775 break;
776 }
777
778 iOutRet = CTvProgram::selectByID ( progId, prog );
779
780 if ( 0 != iOutRet ) {
781 break;
782 }
783 if (prog.getAudioTrackSize() <= 1) {
784 LOGD("%s, just one audio track, not to switch", __FUNCTION__);
785 break;
786 }
787 if ( idx >= prog.getAudioTrackSize() ) {
788 break;
789 }
790
791 pAudio = prog.getAudio ( idx );
792
793 if ( NULL == pAudio ) {
794 break;
795 }
796
797 aPid = pAudio->getPID();
798 aFmt = pAudio->getFormat();
799
800 if ( aPid < 0 || aFmt < 0 ) {
801 break;
802 }
803
804 iOutRet = mAv.SwitchTSAudio (( uint16_t ) aPid, ( AM_AV_AFormat_t ) aFmt );
805
806 LOGD ( "%s, iOutRet = %d AM_AV_SwitchTSAudio\n", __FUNCTION__, iOutRet );
807 } while ( false );
808
809 return iOutRet;
810}
811
812int CTv::ResetAudioDecoderForPCMOutput()
813{
814 int iOutRet = 0;
815
816 iOutRet = mAv.ResetAudioDecoder ();
817 LOGD ( "%s, iOutRet = %d AM_AV_ResetAudioDecoder\n", __FUNCTION__, iOutRet );
818 return iOutRet;
819}
820int CTv::playDtmbProgram ( int progId )
821{
822 CTvProgram prog;
823 CTvChannel channel;
824 int vpid = 0x1fff, apid = 0x1fff, vfmt = -1, afmt = -1;
825 int aindex;
826 CTvProgram::Audio *pA;
827 CTvProgram::Video *pV;
828 int ret = CTvProgram::selectByID ( progId, prog );
829
830 saveDTVProgramID ( progId );
831 prog.getChannel ( channel );
832 //音量补偿
833 int chanVolCompValue = 0;
834 chanVolCompValue = GetAudioVolumeCompensationVal(progId);
835 SetCurProgramAudioVolumeCompensationVal ( chanVolCompValue );
836
837 mFrontDev.setPara ( channel.getMode(), channel.getFrequency(), channel.getBandwidth(), 0 );
838
839 pV = prog.getVideo();
840
841 if ( pV != NULL ) {
842 vpid = pV->getPID();
843 vfmt = pV->getFormat();
844 }
845
846 aindex = prog.getCurrAudioTrackIndex();
847
848 if ( -1 == aindex ) { //db is default
849 aindex = prog.getCurrentAudio ( String8 ( "eng" ) );
850
851 if ( aindex >= 0 ) {
852 prog.setCurrAudioTrackIndex ( progId, aindex );
853 }
854 }
855
856 if ( aindex >= 0 ) {
857 pA = prog.getAudio ( aindex );
858
859 if ( pA != NULL ) {
860 apid = pA->getPID();
861 afmt = pA->getFormat();
862 }
863 }
864
865 mTvEpg.leaveProgram();
866 mTvEpg.leaveChannel();
867 startPlayTv ( SOURCE_DTV, vpid, apid, vfmt, afmt );
868 mTvEpg.enterChannel ( channel.getID() );
869 mTvEpg.enterProgram ( prog.getID() );
870 return 0;
871}
872
873int CTv::playAtvProgram ( int progId )
874{
875 LOGD ( "%s, progId = %d\n", __FUNCTION__, progId );
876
877 CTvProgram prog;
878
879 if ( CTvProgram::selectByID ( progId, prog ) != 0 ) {
880 LOGE ( "%s, atv progID is not matching the db's\n", __FUNCTION__ );
881 }
882
883 saveATVProgramID ( progId );
884 LOGD ( "%s, prog name = %s\n", __FUNCTION__, prog.getName().string() );
885 CTvChannel channel;
886 prog.getChannel ( channel );
887
888 mTvAudio.SetAudioMuteForTv ( CC_AUDIO_MUTE );
889
890 int chanVolCompValue = 0;
891 chanVolCompValue = GetAudioVolumeCompensationVal(progId);
892 SetCurProgramAudioVolumeCompensationVal ( chanVolCompValue );
893
894 //image selecting channel
895 mSigDetectThread.requestAndWaitPauseDetect();
896 mTvin.Tvin_StopDecoder();
897
898 //set CVBS
899 int audioEnum = CFrontEnd::stdAndColorToAudioEnum(channel.getStd());
900 int videoEnum = CFrontEnd::stdAndColorToVideoEnum(channel.getStd());
901 int fmt = CFrontEnd::stdEnumToCvbsFmt (videoEnum, audioEnum);
902 mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt );
903 m_cur_set_info_fmt = ( tvin_sig_fmt_t )fmt;
904
905 //set TUNER
906 mFrontDev.setPara (FE_ANALOG, channel.getFrequency(), channel.getStd(), channel.getAfcData());
907
908 if ( channel.getAfcData() != 0 ) {
909 mFrontDev.fineTune ( channel.getAfcData() / 1000 );
910 }
911
912 mSigDetectThread.initSigState();
913 mSigDetectThread.resumeDetect();
914 return 0;
915}
916
917int CTv::resetFrontEndPara ( frontend_para_set_t feParms )
918{
919 if ( feParms.mode == FE_ANALOG ) {
920 int progID = -1;
921 int tmpFreq = feParms.freq;
922 int tmpfineFreq = feParms.para2;
923 int mode = feParms.mode;
924
925 //get tunerStd from videoStd and audioStd
926 v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor (feParms.videoStd, feParms.audioStd);
927
928 //get program dbID saved by last time,if dbID is -1, it shows program hasn't played
929 progID = getATVProgramID();
930
931 LOGD("%s, resetFrontEndPara- vstd=%d astd=%d stdandcolor=%lld", __FUNCTION__, feParms.videoStd, feParms.audioStd, stdAndColor);
932
933 //judge progID matching db's or not
934 CTvProgram prog;
935
936 if ( CTvProgram::selectByID ( progID, prog ) != 0 ) {
937 LOGE ( "%s, atv progID is not matching the db's\n", __FUNCTION__);
938 return 0;
939 }
940
941 //channel fine tune and save freq, std, fineFreq into DB
942 CTvChannel channel;
943 prog.upDateChannel ( channel, stdAndColor, tmpFreq, tmpfineFreq );
944 mFrontDev.fineTune ( tmpfineFreq / 1000 ); //driver fine tune freq khz
945
946
947 //set frontend parameters to tuner dev
948 mSigDetectThread.requestAndWaitPauseDetect();
949 mTvin.Tvin_StopDecoder();
950
951 //set CVBS
952 int fmt = CFrontEnd::stdEnumToCvbsFmt (feParms.videoStd, feParms.audioStd );
953 mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt );
954 m_cur_set_info_fmt = ( tvin_sig_fmt_t )fmt;
955
956 //set TUNER
957 usleep(400 * 1000);
958 mFrontDev.setPara ( FE_ANALOG, tmpFreq, stdAndColor, tmpfineFreq );
959 usleep(400 * 1000);
960 if ( tmpfineFreq != 0 ) {
961 mFrontDev.fineTune ( tmpfineFreq / 1000 );
962 }
963
964 mSigDetectThread.initSigState();
965 mSigDetectThread.resumeDetect();
966 } else if ( feParms.mode == FE_DTMB ) {
967 mFrontDev.setPara ( FE_DTMB, feParms.freq, feParms.para1, feParms.para2 );
968 }
969
970 return 0;
971}
972
973int CTv::resetDmxAndAvSource()
974{
975 AM_DMX_Source_t curdmxSource;
976 mFrontDev.GetTSSource ( &curdmxSource );
977 LOGD ( "%s, AM_FEND_GetTSSource %d", __FUNCTION__, curdmxSource );
978 mTvDmx.Close();
979 AM_DMX_OpenPara_t para;
980 memset ( &para, 0, sizeof ( para ) );
981 mTvDmx.Open (para);
982 mTvDmx.SetSource(curdmxSource );
983 AM_AV_TSSource_t ts_source = ( AM_AV_TSSource_t ) curdmxSource;
984 mAv.SetTSSource (ts_source );
985 return 0;
986}
987
988int CTv::SetCurProgramAudioVolumeCompensationVal ( int tmpVal )
989{
990 mTvAudio.SetAudioVolumeCompensationVal ( tmpVal );
991 mTvAudio.SetAudioMasterVolume (mTvAudio.GetAudioMasterVolume() );
992
993 LOGD ( "%s, VolumeCompensationVal = %d, id = %d\n", __FUNCTION__, tmpVal, m_cur_playing_prog_id );
994 CTvProgram prog;
995 if ( CTvProgram::selectByID ( m_cur_playing_prog_id, prog ) != 0 ) {
996 LOGE ( "%s, atv progID is not matching the db's ret = 0\n", __FUNCTION__ );
997 return -1;
998 }
999
1000 if (prog.updateVolComp ( m_cur_playing_prog_id, tmpVal ) != 0 ) {
1001 LOGE ( "%s, atv progID is not matching the db's\n", __FUNCTION__);
1002 return -1;
1003 }
1004 return 0;
1005}
1006
1007int CTv::GetAudioVolumeCompensationVal(int progxxId)
1008{
1009 int tmpVolValue = 0;
1010 CTvProgram prog;
1011 if ( CTvProgram::selectByID ( m_cur_playing_prog_id, prog ) != 0 ) {
1012 LOGE ( "%s, atv progID is not matching the db's ret = 0\n", __FUNCTION__ );
1013 return tmpVolValue;
1014 }
1015 tmpVolValue = prog.getChanVolume ();
1016 LOGD ( "%s,progid = %d CompensationVal = %d\n", __FUNCTION__, m_cur_playing_prog_id, tmpVolValue );
1017 if (tmpVolValue > 20 || tmpVolValue < -20) tmpVolValue = 0;
1018 return tmpVolValue;
1019}
1020
1021int CTv::startPlayTv ( int source, int vid, int aid, int vfat, int afat )
1022{
1023 int ret = 0;
1024
1025 if ( source == SOURCE_DTV ) {
1026 AM_FileEcho ( DEVICE_CLASS_TSYNC_AV_THRESHOLD_MIN, AV_THRESHOLD_MIN_MS );
1027 LOGD ( "%s, startPlayTv", __FUNCTION__);
1028 mAv.StartTS (vid, aid, ( AM_AV_VFormat_t ) vfat, ( AM_AV_AFormat_t ) afat );
1029 } else {
1030
1031 }
1032 return ret;
1033}
1034
1035int CTv::stopPlayingLock()
1036{
1037 AutoMutex lock ( mLock );
1038 return stopPlaying();
1039}
1040
1041int CTv::stopPlaying()
1042{
1043 if (!(mTvAction & TV_ACTION_PLAYING)) {
1044 LOGD("%s, stopplay cur action = %x not playing , return", __FUNCTION__, mTvAction);
1045 return 0;
1046 }
1047 mAv.EnableVideoBlackout();
1048 if (m_source_input == SOURCE_TV) {
1049 //first mute
1050 mTvAudio.SetAudioMuteForTv(CC_AUDIO_MUTE);
1051 ClearAnalogFrontEnd();
1052 } else if (m_source_input == SOURCE_DTV) {
1053 //mFrontDev.setPara(FE_DTMB, 51000000, 0, 0);
1054 mAv.StopTS ();
1055 mTvEpg.leaveChannel();
1056 mTvEpg.leaveProgram();
1057 }
1058 mAv.DisableVideoWithBlueColor();
1059 mTvAction = mTvAction & ~TV_ACTION_PLAYING;
1060 return 0;
1061}
1062
1063int CTv::getAudioChannel()
1064{
1065 int iRet = -1;
1066 AM_AOUT_OutputMode_t audioChanneleMod;
1067 do {
1068 iRet = mAv.AudioGetOutputMode (&audioChanneleMod );
1069 if ( AM_SUCCESS != iRet ) {
1070 LOGD ( "%s, jianfei.lan GetOutputMode is FAILED %d\n", __FUNCTION__, iRet );
1071 break;
1072 }
1073 LOGD ( "%s, jianfei.lan getAudioChannel iRet : %d audioChanneleMod %d\n", __FUNCTION__, iRet, audioChanneleMod );
1074 } while ( 0 );
1075 return audioChanneleMod;
1076}
1077
1078int CTv::setAudioChannel ( int channelIdx )
1079{
1080 int iOutRet = 0;
1081 AM_AOUT_OutputMode_t audioChanneleMod;
1082 LOGD ( "%s, channelIdx : %d\n", __FUNCTION__, channelIdx );
1083 audioChanneleMod = ( AM_AOUT_OutputMode_t ) channelIdx;
1084 iOutRet = mAv.AudioSetOutputMode (audioChanneleMod );
1085 if ( AM_SUCCESS != iOutRet) {
1086 LOGD ( "%s, jianfei.lan %s AM_AOUT_SetOutputMode device is FAILED %d\n", __FUNCTION__, "TV", iOutRet );
1087 }
1088 return 0;
1089}
1090
1091int CTv::getFrontendSignalStrength()
1092{
1093 int Strength = 0;
1094 Strength = mFrontDev.getStatus();
1095 return Strength;
1096}
1097
1098int CTv::getFrontendSNR()
1099{
1100 int snr = 0;
1101 snr = mFrontDev.getSNR();
1102 return snr;
1103}
1104
1105int CTv::getFrontendBER()
1106{
1107 int ber = 0;
1108 ber = mFrontDev.getBER();
1109 return ber;
1110
1111}
1112
1113int CTv::getChannelInfoBydbID ( int dbID, channel_info_t &chan_info )
1114{
1115 CTvProgram prog;
1116 CTvChannel channel;
1117 Vector<sp<CTvProgram> > out;
1118 memset ( &chan_info, sizeof ( chan_info ), 0 );
1119 chan_info.freq = 44250000;
1120 chan_info.uInfo.atvChanInfo.videoStd = CC_ATV_VIDEO_STD_PAL;
1121 chan_info.uInfo.atvChanInfo.audioStd = CC_ATV_AUDIO_STD_DK;
1122
1123 int ret = CTvProgram::selectByID ( dbID, prog );
1124 if ( ret != 0 ) {
1125 LOGD ( "getChannelinfo , select dbid=%d,is not exist", dbID);
1126 return -1;
1127 }
1128 prog.getChannel ( channel );
1129
1130 if ( CTvProgram::TYPE_ATV == prog.getProgType() ) {
1131 chan_info.freq = channel.getFrequency();
1132 chan_info.uInfo.atvChanInfo.finefreq = channel.getAfcData();
1133 LOGD("%s, get channel std = %lld", __FUNCTION__, channel.getStd());
1134 chan_info.uInfo.atvChanInfo.videoStd =
1135 ( atv_video_std_t ) CFrontEnd::stdAndColorToVideoEnum ( channel.getStd() );
1136 chan_info.uInfo.atvChanInfo.audioStd =
1137 ( atv_audio_std_t ) CFrontEnd::stdAndColorToAudioEnum ( channel.getStd() );
1138 chan_info.uInfo.atvChanInfo.isAutoStd = ((channel.getStd() & V4L2_COLOR_STD_AUTO) == V4L2_COLOR_STD_AUTO) ? 1 : 0;
1139 } else if ( CTvProgram::TYPE_DTV == prog.getProgType() || CTvProgram::TYPE_RADIO == prog.getProgType()) {
1140 chan_info.freq = channel.getFrequency();
1141 chan_info.uInfo.dtvChanInfo.strength = getFrontendSignalStrength();
1142 chan_info.uInfo.dtvChanInfo.quality = getFrontendSNR();
1143 chan_info.uInfo.dtvChanInfo.ber = getFrontendBER();
1144 }
1145
1146 return 0;
1147}
1148
1149bool CTv::Tv_Start_Analyze_Ts ( int channelID )
1150{
1151 int freq, ret;
1152 CTvChannel channel;
1153
1154 AutoMutex lock ( mLock );
1155 mAv.StopTS ();
1156 mAv.DisableVideoWithBlueColor();
1157 ret = CTvChannel::selectByID ( channelID, channel );
1158
1159 if ( ret != 0 ) {
1160 LOGD ( "%s, CTv tv_updatats can not get freq by channel ID", __FUNCTION__ );
1161 return false;
1162 }
1163
1164 mTvAction = mTvAction | TV_ACTION_SCANNING;
1165 freq = channel.getFrequency();
1166 LOGD ( "%s, the freq = %d", __FUNCTION__, freq );
1167 mDtvScanRunningStatus = DTV_SCAN_RUNNING_ANALYZE_CHANNEL;
1168 mTvScanner.setObserver ( &mTvMsgQueue );
1169 mTvScanner.manualDtmbScan ( freq, freq ); //dtmb
1170 return true;
1171}
1172
1173bool CTv::Tv_Stop_Analyze_Ts()
1174{
1175 stopScanLock();
1176 return true;
1177}
1178
1179
1180int CTv::saveATVProgramID ( int dbID )
1181{
1182 config_set_int ( "TV", "atv.get.program.id", dbID );
1183 return 0;
1184}
1185
1186int CTv::getATVProgramID ( void )
1187{
1188 return config_get_int ( "TV", "atv.get.program.id", -1 );
1189}
1190
1191int CTv::saveDTVProgramID ( int dbID )
1192{
1193 config_set_int ( "TV", "dtv.get.program.id", dbID );
1194 return 0;;
1195}
1196
1197int CTv::getDTVProgramID ( void )
1198{
1199 return config_get_int ( "TV", "dtv.get.program.id", -1 );
1200}
1201
1202int CTv::getATVMinMaxFreq ( int *scanMinFreq, int *scanMaxFreq )
1203{
1204 int tmpVal, i = 0;
1205 const char *config_value;
1206 const char *strDelimit = ",";
1207 char *token = NULL;
1208
1209 *scanMinFreq = 44250000;
1210 *scanMaxFreq = 868250000;
1211
1212 config_value = config_get_str ( "ATV", "atv.get.min.max.freq", "null" );
1213
1214 if ( strcmp ( config_value, "null" ) == 0 ) {
1215 LOGD ( "%s, atv.get.min.max.freq not set config\n", __FUNCTION__ );
1216 return -1;
1217 }
1218
1219 char data_str[512];
1220 memset ( ( void * ) data_str, 0, sizeof ( data_str ) );
1221 strncpy ( data_str, config_value, sizeof ( data_str ) - 1 );
1222
1223 token = strtok ( data_str, strDelimit );
1224 sscanf ( token, "%d", scanMinFreq );
1225 token = strtok ( NULL, strDelimit );
1226
1227 if ( token != NULL ) {
1228 sscanf ( token, "%d", scanMaxFreq );
1229 return 0;
1230 }
1231 return 0;
1232}
1233
1234int CTv::IsDVISignal()
1235{
1236 return ( ( TVIN_SIG_FMT_NULL != mSigDetectThread.getCurSigInfo().fmt ) && ( mSigDetectThread.getCurSigInfo().reserved & 0x1 ) );
1237}
1238
1239int CTv::getHDMIFrameRate()
1240{
1241 int ConstRate[5] = {24, 25, 30, 50, 60};
1242 float ConstRateDiffHz[5] = {0.5, 0.5, 0.5, 2, 2}; //偏差值
1243 int fps = mSigDetectThread.getCurSigInfo().fps;
1244 int i = 0;
1245 for (; i < 5; i++) {
1246 if (abs(ConstRate[i] - fps) < ConstRateDiffHz[i])
1247 fps = ConstRate[i];
1248 }
1249 return fps;
1250}
1251
1252tv_source_input_t CTv::GetLastSourceInput ( void )
1253{
1254 return m_last_source_input;
1255}
1256
1257int CTv::isVgaFmtInHdmi ( void )
1258{
1259 tvin_sig_fmt_t fmt = mSigDetectThread.getCurSigInfo().fmt;
1260
1261 if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI ) {
1262 return -1;
1263 }
1264
1265 return CTvin::isVgaFmtInHdmi ( fmt );
1266}
1267
1268int CTv::SetBypassModulesFor3D ( VIDEO_3D_MODE_E mode )
1269{
1270 LOGD ( "%s, ----> Set mode(%d) <----", __FUNCTION__, mode );
1271 const char *config_value = NULL;
1272
1273 int DIBypassAllFlag = 0;
1274 config_value = config_get_str ( "TV", "tvin.di.bypass_all", "null" );//bypass , if
1275 if (strcasecmp(config_value, "true") == 0 || strcasecmp(config_value, "1") == 0) {
1276 DIBypassAllFlag = 1;
1277 } else {
1278 DIBypassAllFlag = 0;
1279 }
1280
1281
1282 switch (mode) {
1283 case VIDEO_3D_MODE_DISABLE: {
1284 mTvin.VDIN_SetDIBypassAll ( 0 );
1285 mTvin.VDIN_SetDIBypassPost ( 0 );
1286 // mTvin.VDIN_SetDISip_Top_Bot ( 0 );
1287 }
1288 break;
1289 case VIDEO_3D_MODE_AUTO: {
1290 mTvin.VDIN_SetDIBypassAll ( 0 );
1291 mTvin.VDIN_SetDIBypassPost ( 1 );
1292 // mTvin.VDIN_SetDISip_Top_Bot ( 0 );
1293
1294
1295 }
1296 break;
1297 case VIDEO_3D_MODE_LR:
1298 case VIDEO_3D_MODE_TB: {
1299 mTvin.VDIN_SetDIBypassPost ( 1 );
1300 usleep ( 20 * 1000 );
1301 mTvin.VDIN_SetDIBypassAll ( 1 | DIBypassAllFlag );
1302 //mTvin.VDIN_SetDISip_Top_Bot ( 1 );
1303 }
1304 break;
1305 case VIDEO_3D_MODE_LA:
1306 case VIDEO_3D_MODE_FA: {
1307 mTvin.VDIN_SetDIBypassPost ( 1 );
1308 usleep ( 20 * 1000 );
1309 mTvin.VDIN_SetDIBypassAll ( 0 );
1310 //mTvin.VDIN_SetDISip_Top_Bot ( 0 );
1311 }
1312 break;
1313 default:
1314 break;
1315 }
1316
1317 if (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_DTV ) {
1318 if ( mode == VIDEO_3D_MODE_DISABLE ) {
1319 mTvin.VDIN_SetVdinFlag ( MEMP_DCDR_WITHOUT_3D );
1320 } else {
1321 mTvin.VDIN_SetVdinFlag ( MEMP_DCDR_WITH_3D );
1322 }
1323 } else {
1324 if ( mode == VIDEO_3D_MODE_DISABLE ) {
1325 if ( m_source_input == SOURCE_TV ) {
1326 mTvin.VDIN_SetVdinFlag ( MEMP_ATV_WITHOUT_3D );
1327 } else {
1328 mTvin.VDIN_SetVdinFlag ( MEMP_VDIN_WITHOUT_3D );
1329 }
1330 } else {
1331 if ( m_source_input == SOURCE_TV ) {
1332 mTvin.VDIN_SetVdinFlag ( MEMP_ATV_WITH_3D );
1333 } else {
1334 mTvin.VDIN_SetVdinFlag ( MEMP_VDIN_WITH_3D );
1335 }
1336 }
1337 }
1338
1339 return 0;
1340}
1341
1342void CTv::print_version_info ( void )
1343{
1344 // print tvapi version info
1345 LOGD ( "libtvservice git branch:%s\n", tvservice_get_git_branch_info() );
1346 LOGD ( "libtvservice git version:%s\n", tvservice_get_git_version_info() );
1347 LOGD ( "libtvservice Last Changed:%s\n", tvservice_get_last_chaned_time_info() );
1348 LOGD ( "libtvservice Last Build:%s\n", tvservice_get_build_time_info() );
1349 LOGD ( "libtvservice Builer Name:%s\n", tvservice_get_build_name_info() );
1350 LOGD ( "libtvservice board version:%s\n", tvservice_get_board_version_info() );
1351 LOGD ( "\n\n");
1352 // print dvb version info
1353 LOGD ( "libdvb git branch:%s\n", dvb_get_git_branch_info() );
1354 LOGD ( "libdvb git version:%s\n", dvb_get_git_version_info() );
1355 LOGD ( "libdvb Last Changed:%s\n", dvb_get_last_chaned_time_info() );
1356 LOGD ( "libdvb Last Build:%s\n", dvb_get_build_time_info() );
1357 LOGD ( "libdvb Builer Name:%s\n", dvb_get_build_name_info() );
1358}
1359
1360int CTv::Tvin_GetTvinConfig ( void )
1361{
1362 const char *config_value;
1363 int i = 0;
1364
1365 config_value = config_get_str ( "TV", "tvin.overscan.3d", "null" );
1366
1367 if ( strcmp ( config_value, "enable" ) == 0 ) {
1368 gTvinConfig.overscan_3d = 1;
1369 } else {
1370 gTvinConfig.overscan_3d = 0;
1371 }
1372
1373 config_value = config_get_str ( "TV", "tvin.tv.out.counter", "null" );
1374 gTvinConfig.tv_out_counter = ( unsigned int ) strtol ( config_value, NULL, 6 );
1375
1376 if ( gTvinConfig.tv_out_counter <= 0 || gTvinConfig.tv_out_counter > 8 ) {
1377 gTvinConfig.tv_out_counter = 6;
1378 }
1379
1380 config_value = config_get_str ( "TV", "tvin.kernelpet_disable", "null" );
1381
1382 if ( strcmp ( config_value, "disable" ) == 0 ) {
1383 gTvinConfig.kernelpet_disable = true;
1384 } else {
1385 gTvinConfig.kernelpet_disable = false;
1386 }
1387
1388 config_value = config_get_str ( "TV", "tvin.kernelpet.timeout", "null" );
1389 gTvinConfig.userpet_timeout = ( unsigned int ) strtol ( config_value, NULL, 10 );
1390
1391 if ( gTvinConfig.kernelpet_timeout <= 0 || gTvinConfig.kernelpet_timeout > 40 ) {
1392 gTvinConfig.kernelpet_timeout = 10;
1393 }
1394
1395
1396 config_value = config_get_str ( "TV", "tvin.userpet", "null" );
1397
1398 if ( strcmp ( config_value, "enable" ) == 0 ) {
1399 gTvinConfig.userpet = true;
1400 } else {
1401 gTvinConfig.userpet = false;
1402 }
1403
1404 config_value = config_get_str ( "TV", "tvin.userpet.timeout", "null" );
1405 gTvinConfig.userpet_timeout = ( unsigned int ) strtol ( config_value, NULL, 10 );
1406
1407 if ( gTvinConfig.userpet_timeout <= 0 || gTvinConfig.userpet_timeout > 100 ) {
1408 gTvinConfig.userpet_timeout = 10;
1409 }
1410
1411 config_value = config_get_str ( "TV", "tvin.userpet.reset", "null" );
1412
1413 if ( strcmp ( config_value, "disable" ) == 0 ) {
1414 gTvinConfig.userpet_reset = 0;
1415 } else {
1416 gTvinConfig.userpet_reset = 1;
1417 }
1418
1419 config_value = config_get_str ( "TV", "tvin.title_shake", "null" );
1420
1421 if ( strcmp ( config_value, "enable" ) == 0 ) {
1422 gTvinConfig.title_shake = true;
1423 } else {
1424 gTvinConfig.title_shake = false;
1425 }
1426
1427 return 0;
1428}
1429
1430int CTv::SetAudioMainVolLutBufName()
1431{
1432 int i = 0;
1433 const char *tmp_ptr = NULL;
1434 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 };
1435 const char *end_str_buf[6] = { ".tv", ".av", ".comp", ".hdmi", ".vga", ".mpeg", };
1436 project_info_t tmp_info;
1437 char tmp_buf[128];
1438 char value_buf[128];
1439 char key_buf[128];
1440
1441 int name_en = GetAudioMainVolLutBufNameModifyEnableCFG();
1442
1443 if (name_en == 1) {
1444 strcpy(tmp_buf, "null");
1445 if (GetProjectInfo(&tmp_info) == 0) {
1446 strncpy(tmp_buf, tmp_info.amp_curve_name, CC_PROJECT_INFO_ITEM_MAX_LEN - 1);
1447 }
1448
1449 if (strcmp(tmp_buf, "null") != 0) {
1450 for ( i = 0; i < 6; i++ ) {
1451 memset(value_buf, '\0', sizeof(value_buf));
1452 memset(key_buf, '\0', sizeof(key_buf));
1453
1454 GetAudioMainVolLutBufNameCFG(get_type_buf[i], key_buf);
1455
1456 strcpy(value_buf, tmp_buf);
1457 strcat(value_buf, end_str_buf[i]);
1458
1459 tmp_ptr = config_get_str("TV", key_buf, "null");
1460 if (strcmp(tmp_ptr, value_buf) != 0) {
1461 config_set_str("TV", key_buf, value_buf);
1462 LOGD("%s, config string now set as: %s \n", __FUNCTION__, value_buf);
1463 } else {
1464 LOGD("%s, config string has been set as: %s \n", __FUNCTION__, value_buf);
1465 }
1466 }
1467 }
1468 }
1469
1470 return 0;
1471}
1472
1473int CTv::SetAudioSupperBassVolLutBufName()
1474{
1475 int i = 0;
1476 const char *tmp_ptr = NULL;
1477 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 };
1478 const char *end_str_buf[6] = { ".tv", ".av", ".comp", ".hdmi", ".vga", ".mpeg", };
1479 project_info_t tmp_info;
1480 char tmp_buf[128];
1481 char value_buf[128];
1482 char key_buf[128];
1483
1484 int name_en = GetAudioSupperBassVolLutBufNameModifyEnableCFG();
1485
1486 if (name_en == 1) {
1487 strcpy(tmp_buf, "null");
1488 if (GetProjectInfo(&tmp_info) == 0) {
1489 strncpy(tmp_buf, tmp_info.amp_curve_name, CC_PROJECT_INFO_ITEM_MAX_LEN - 1);
1490 }
1491
1492 if (strcmp(tmp_buf, "null") != 0) {
1493 for ( i = 0; i < 6; i++ ) {
1494 memset(value_buf, '\0', sizeof(value_buf));
1495 memset(key_buf, '\0', sizeof(key_buf));
1496
1497 GetAudioSupperBassVolLutBufNameCFG(get_type_buf[i], key_buf);
1498
1499 strcpy(value_buf, tmp_buf);
1500 strcat(value_buf, ".sup");
1501 strcat(value_buf, end_str_buf[i]);
1502
1503 tmp_ptr = config_get_str("TV", key_buf, "null");
1504 if (strcmp(tmp_ptr, value_buf) != 0) {
1505 config_set_str("TV", key_buf, value_buf);
1506 LOGD("%s, config string now set as: %s \n", __FUNCTION__, value_buf);
1507 } else {
1508 LOGD("%s, config string has been set as: %s \n", __FUNCTION__, value_buf);
1509 }
1510 }
1511 }
1512 }
1513
1514 return 0;
1515}
1516
1517TvRunStatus_t CTv::GetTvStatus()
1518{
1519 return mTvStatus;
1520}
1521
1522int CTv::OpenTv ( void )
1523{
1524 int tmp_val = 0;
1525 const char *value;
1526 //reboot system by fbc setting.
1527 value = config_get_str ( "TV", "fbc.get.panelinfo", "null" );
1528 LOGD("%s fbc-------------------\n", value);
1529 if ( strcmp ( value, "edid" ) == 0 ) {
1530 if (reboot_sys_by_fbc_edid_info() == 0) {
1531 }
1532 } else if ( strcmp ( value, "uart" ) == 0 ) {
1533 if (reboot_sys_by_fbc_uart_panel_info() == 0) {
1534 }
1535 }
1536
1537 LOGD ( "%s, tv open\n", __FUNCTION__);
1538 char prop_value[PROPERTY_VALUE_MAX];
1539 memset ( prop_value, '\0', PROPERTY_VALUE_MAX );
1540
1541 mTvin.Tvin_LoadSourceInputToPortMap();
1542
1543 SSMSave3DLRSwitch ( 0 );
1544 SSMSave3DTO2D ( 0 );
1545 //
1546 SSMHandlePreCopying();
1547 if ( SSMDeviceMarkCheck() < 0 ) {
1548 SSMRestoreDeviceMarkValues();
1549 Tv_SSMRestoreDefaultSetting();
1550 }
1551 mTvin.OpenTvin();
1552 mTvin.init_vdin();
1553 mTvin.Tv_init_afe();
1554 mVpp.Vpp_Init();
1555 SetAudioSupperBassVolLutBufName();
1556 SetAudioMainVolLutBufName();
1557 mTvAudio.AudioCtlInitializeLoad();
1558
1559 SSMSetHDCPKey();
1560 system ( "/system/bin/dec" );
1561
1562 //set color filter
1563 // SetFileAttrValue ( "/sys/module/amvideo/parameters/filt_mode", "0x2100" );
1564
1565 if ( gTvinConfig.title_shake) {
1566 SetFileAttrValue ( "/sys/module/di/parameters/di_new_mode_mask", "0x10000" );
1567 }
1568
1569 value = config_get_str ( "TV", "tvin.autoset.displayfreq", "null" );
1570
1571 if ( strcmp ( value, "enable" ) == 0 ) {
1572 m_autoset_displayfreq = true;
1573 } else {
1574 m_autoset_displayfreq = false;
1575 }
1576
1577 if (mTvin.VDIN_GetDisplayVFreq() == 30) {
1578 m_autoset_displayfreq = false;
1579 }
1580
1581 if (GetPlatformHaveDDFlag() == 1) {
1582 SetFileAttrValue ("/sys/module/tvin_hdmirx/parameters/edid_mode", "0x109");
1583 }
1584
1585 value = config_get_str ( "TV", "ssm.handle.hdmi.edid.en", "null" );
1586
1587 if ( strtoul(value, NULL, 10) == 1 ) {
1588 LOGD( "%s, get config \"%s\" is \"%s\".\n",
1589 __FUNCTION__, "ssm.handle.hdmi.edid.en", value );
1590 //get hdmi edid use mode
1591 char prop_value[256];
1592 memset( prop_value, '\0', 256 );
1593 property_get( "ubootenv.var.outputmode", prop_value, "null" );
1594 LOGD( "%s, get property \"%s\" is \"%s\".\n",
1595 __FUNCTION__, "ubootenv.var.outputmode", prop_value );
1596 if ( strcmp ( prop_value, "null" ) != 0 ) {
1597 config_set_str ( "TV", "ssm.handle.hdmi.edid.use", prop_value );
1598 int i;
1599 char edid_path[256];
1600 char edid_path_cfg[256];
1601 //set file's path for hdmi edid of each port
1602 for ( i = 1; i <= SSM_HDMI_PORT_MAX; i++ ) {
1603 memset( edid_path, '\0', 256 );
1604 memset( edid_path_cfg, '\0', 256 );
1605 sprintf ( edid_path, "/system/etc/%s_port%d.bin", prop_value, i );
1606 sprintf ( edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i );
1607 config_set_str ( "TV", edid_path_cfg, edid_path );
1608 }
1609 } else {
1610 //set default hdmi edid
1611 config_set_str ( "TV", "ssm.handle.hdmi.edid.use", "hdmi_edid" );
1612 int i;
1613 char edid_path[256];
1614 char edid_path_cfg[256];
1615 //set file's path for hdmi edid of each port
1616 for ( i = 1; i <= SSM_HDMI_PORT_MAX; i++ ) {
1617 memset( edid_path, '\0', 256 );
1618 memset( edid_path_cfg, '\0', 256 );
1619 sprintf ( edid_path, "/system/etc/%s_port%d.bin", "hdmi_edid", i );
1620 sprintf ( edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i );
1621 config_set_str ( "TV", edid_path_cfg, edid_path );
1622 }
1623 }
1624 m_is_set_hdmi_edid = true;
1625 }
1626 //
1627 unsigned char val = 0;
1628 Tvin_GetTvinConfig();
1629 m_last_source_input = SOURCE_INVALID;
1630 m_source_input = SOURCE_INVALID;
1631 m_mode_3d = VIDEO_3D_MODE_DISABLE;
1632 m_is_hdmi_sr_detect_start = false;
1633 m_hdmi_sampling_rate = 0;
1634 int8_t blackout_enable;
1635 SSMReadBlackoutEnable(&blackout_enable);
1636 m_blackout_enable = blackout_enable;
1637
1638
1639 //
1640 //dtv init
1641 int rt = -1;
1642 //opendemux();
1643 rt = mFrontDev.Open(FE_ANALOG);
1644 mFrontDev.autoLoadFE();
1645 AM_DMX_OpenPara_t para_dmx;
1646 memset ( &para_dmx, 0, sizeof ( AM_DMX_OpenPara_t ) );
1647 mTvDmx.Open(para_dmx );
1648 mTvDmx.SetSource (AM_DMX_SRC_TS2);
1649 mAv.Open();
1650 mTvEpg.Init ( 0, 0, 1, "eng zho chi", "GB2312" );
1651 resetDmxAndAvSource();
1652 mSourceConnectDetectThread.startDetect();
1653
1654 if (SSMReadSerialCMDSwitchValue() == 1) {
1655 SetSerialSwitch(SERIAL_A, 1);
1656 }
1657 mTvin.VDIN_SetVdinFlag ( MEMP_DCDR_WITHOUT_3D );
1658 mTvin.VDIN_SetMVCViewMode(0);//for not 3d screen
1659 ClearAnalogFrontEnd();
1660
1661 mTvStatus = TV_OPEN_ED;
1662
1663 mHDMIRxCEC.start();
1664
1665 return 0;
1666}
1667
1668int CTv::CloseTv ( void )
1669{
1670 LOGD ( "%s, tv close");
1671 mSigDetectThread.stopDetect();
1672 if (mpUpgradeFBC != NULL) {
1673 mpUpgradeFBC->stop();
1674 }
1675 mTvin.Tv_uninit_afe();
1676 mTvin.uninit_vdin();
1677 mVpp.Vpp_Uninit();
1678 TvMisc_DisableWDT ( gTvinConfig.userpet );
1679 mTvStatus = TV_CLOSE_ED;
1680 return 0;
1681}
1682
1683
1684int CTv::StartTvLock ()
1685{
1686 LOGD ( "%s, tv start status = %d", __FUNCTION__, mTvStatus);
1687 if (mTvStatus == TV_START_ED)
1688 return 0;
1689
1690 Mutex::Autolock _l ( mLock );
1691 mTvAction = mTvAction | TV_ACTION_STARTING;
1692 mTvAudio.SwitchAVOutBypass(0);
1693 mTvAudio.AudioCtlInit();
1694 mFrontDev.Open(FE_ANALOG);
1695 mSigDetectThread.startDetect();
1696 mSigDetectThread.pauseDetect();
1697 mSigDetectThread.initSigState();
1698 mTvMsgQueue.startMsgQueue();
1699 resetDmxAndAvSource();
1700 Vpp_SetDisplayMode ( mVpp.Tv_GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt);
1701 TvMisc_EnableWDT ( gTvinConfig.kernelpet_disable, gTvinConfig.userpet, gTvinConfig.kernelpet_timeout, gTvinConfig.userpet_timeout, gTvinConfig.userpet_reset );
1702 am_phase_t am_phase;
1703 if (mVpp.getPqData()->PQ_GetPhaseArray ( &am_phase ) == 0 ) {
1704 mTvin.TvinApi_SetCompPhase(am_phase);
1705 }
1706 mTvin.TvinApi_SetCompPhaseEnable ( 1 );
1707 mTvin.VDIN_EnableRDMA ( 1 );
1708 mTvin.VDIN_SetDIBypasshd ( 0 );
1709
1710 SetBypassModulesFor3D ( VIDEO_3D_MODE_DISABLE );
1711 //win pos
1712 tvin_window_pos_t win_pos;
1713 Vpp_GetDisplayResolutionInfo(&win_pos);
1714 SetPreviewWindow ( win_pos );
1715
1716 mTvin.Tvin_RemovePath ( TV_PATH_TYPE_TVIN );
1717 if ( mTvin.Tvin_RemovePath ( TV_PATH_TYPE_DEFAULT ) ) {
1718 mTvin.Tvin_AddPath ( TV_PATH_DECODER_NEW3D_WITHOUTPPMGR_AMVIDEO );
1719 }
1720 mTvin.VDIN_SetVdinFlag ( MEMP_DCDR_WITHOUT_3D );
1721
1722 mAv.SetVideoWindow (0, 0, 0, 0 );
1723
1724 mTvAction = mTvAction & ~TV_ACTION_STARTING;
1725 mTvStatus = TV_START_ED;
1726 return 0;
1727}
1728int CTv::StopTvLock ( void )
1729{
1730 LOGD("%s, call Tv_Stop status = %d \n", __FUNCTION__, mTvStatus);
1731 const char *value;
1732 Mutex::Autolock _l ( mLock );
1733 //we should stop audio first for audio mute.
1734 mTvAction = mTvAction | TV_ACTION_STOPING;
1735 mSigDetectThread.requestAndWaitPauseDetect();
1736 mAv.EnableVideoBlackout();
1737 //stop scan if scanning
1738 if (mTvAction & TV_ACTION_SCANNING) {
1739 LOGD("%s, scanning first stop it\n", __FUNCTION__)
1740 mTvEpg.leaveChannel();
1741 mTvScanner.stopScan();
1742 mTvAction = mTvAction & ~TV_ACTION_SCANNING;
1743 }
1744 //first stop play(if playing)
1745 stopPlaying();
1746 //
1747 mTvAudio.SwitchAVOutBypass(0);
1748 tv_audio_channel_e audio_channel = mTvin.Tvin_GetInputSourceAudioChannelIndex (SOURCE_MPEG);
1749 mTvAudio.AudioLineInSelectChannel( audio_channel );
1750 mTvAudio.AudioCtlUninit();
1751 mTvin.Tvin_StopDecoder();
1752 mTvin.Tvin_RemovePath ( TV_PATH_TYPE_TVIN );
1753 Tv_Set3DMode(VIDEO_3D_MODE_DISABLE);
1754 mTvAudio.SetAudioMuteForTv ( CC_AUDIO_UNMUTE );
1755 tvin_window_pos_t win_pos;
1756 Vpp_GetDisplayResolutionInfo(&win_pos);
1757 SetPreviewWindow (win_pos );
1758 mVpp.Tv_LoadVppSettings ( SOURCE_TYPE_MPEG, TVIN_SIG_FMT_NULL, INDEX_2D, TVIN_TFMT_2D );
1759 Vpp_SetDisplayMode ( mVpp.Tv_GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(SOURCE_MPEG) ), CTvin::Tvin_SourceInputToSourceInputType(SOURCE_MPEG), mSigDetectThread.getCurSigInfo().fmt);
1760 RefreshAudioMasterVolume ( SOURCE_MPEG );
1761 mVpp.VPP_SetVideoCrop ( 0, 0, 0, 0 );
1762 m_last_source_input = SOURCE_INVALID;
1763 m_source_input = SOURCE_INVALID;
1764 mAv.DisableVideoWithBlackColor();
1765 mAv.ClearVideoBuffer();
1766 mFrontDev.Close();
1767 mTvAction = mTvAction & ~TV_ACTION_STOPING;
1768 mTvStatus = TV_STOP_ED;
1769 value = config_get_str ( "TV", "tvin.2d4G.headset.en", "null" );
1770 if ( strcmp ( value, "enable" ) == 0 ) {
1771 property_set("audio.tv_open.flg", "0");
1772 }
1773
1774 Tv_SetDDDRCMode(SOURCE_MPEG);
1775 return 0;
1776}
1777
1778int CTv::Tv_MiscSetBySource ( tv_source_input_t source_input )
1779{
1780 int ret = -1;
1781
1782 switch ( source_input ) {
1783 case SOURCE_TV:
1784 ret = SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "4" );
1785 break;
1786
1787 case SOURCE_HDMI1:
1788 case SOURCE_HDMI2:
1789 case SOURCE_HDMI3:
1790 //ret = mVpp.Tv_SavePanoramaMode ( VPP_PANORAMA_MODE_FULL, SOURCE_TYPE_HDMI );
1791 ret |= SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "5" );
1792 break;
1793
1794 case SOURCE_DTV:
1795 if ( m_autoset_displayfreq) {
1796 ret = mTvin.VDIN_SetDisplayVFreq ( 50, mAv.getVideoDisplayResolution() , mIsFbc);
1797 }
1798
1799 case SOURCE_AV1:
1800 case SOURCE_AV2:
1801 case SOURCE_VGA:
1802 ret |= SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "5" );
1803 break;
1804
1805 case SOURCE_SVIDEO:
1806 case SOURCE_IPTV:
1807 default:
1808 ret |= SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "5" );
1809 break;
1810 }
1811
1812 return ret;
1813}
1814
1815int CTv::SetSourceSwitchInput (tv_source_input_t source_input )
1816{
1817 Mutex::Autolock _l ( mLock );
1818 LOGD ( "%s, source input = %d", __FUNCTION__, source_input );
1819 tv_source_input_t cur_source_input = m_source_input;
1820 tvin_port_t cur_port;
1821
1822 Tv_SetDDDRCMode(source_input);
1823
1824 if (source_input == cur_source_input ) {
1825 LOGW ( "%s,same input change display mode", __FUNCTION__ );
1826 return 0;
1827 }
1828
1829 //if HDMI, need to set EDID of each port
1830 if (m_is_set_hdmi_edid) {
1831 int tmp_ret = 0;
1832 switch ( source_input ) {
1833 case SOURCE_HDMI1:
1834 tmp_ret = SSMSetHDMIEdid(1);
1835 break;
1836 case SOURCE_HDMI2:
1837 tmp_ret = SSMSetHDMIEdid(2);
1838 break;
1839 case SOURCE_HDMI3:
1840 tmp_ret = SSMSetHDMIEdid(3);
1841 break;
1842 default:
1843 tmp_ret = -1;
1844 break;
1845 }
1846 if (tmp_ret < 0)
1847 LOGE ( "%s, do not set hdmi port%d edid.ret=%d", __FUNCTION__, source_input - 4, tmp_ret );
1848 }
1849 mTvAction = mTvAction | TV_ACTION_SOURCE_SWITCHING;
1850 m_cur_playing_prog_id = -1;
1851 //
1852 CMessage msg;
1853 msg.mType = CTvMsgQueue::TV_MSG_CHECK_FE_DELAY;
1854 msg.mpData = this;
1855 msg.mDelayMs = 3500;//ms
1856 mTvMsgQueue.removeMsg ( msg );
1857 //mute first
1858 mTvAudio.SetAudioMuteForTv(CC_AUDIO_MUTE);
1859 mSigDetectThread.requestAndWaitPauseDetect();
1860 mAv.DisableVideoWithBlueColor();
1861 //enable blackout, when play,disable it
1862 mAv.EnableVideoBlackout();
1863 //set front dev mode
1864 if ( source_input == SOURCE_TV ) {
1865 mFrontDev.Close();
1866 mFrontDev.Open(FE_ANALOG);
1867 //mFrontDev.setMode ( FE_ANALOG );
1868 } else if ( source_input == SOURCE_DTV ) {
1869 mFrontDev.Close();
1870 mFrontDev.Open(FE_ANALOG);
1871 //mFrontDev.setMode ( FE_DTMB);
1872 } else {
1873 mFrontDev.Close();
1874 }
1875
1876 //ok
1877 m_last_source_input = m_source_input;
1878 m_source_input = source_input;
1879 SSMSaveSourceInput ( source_input );
1880
1881 tv_source_input_t pre_source_input = cur_source_input;//change
1882 cur_source_input = source_input;
1883
1884 mTvAudio.SetAudioVolumeCompensationVal ( 0 );
1885
1886 if ( source_input == SOURCE_DTV ) {
1887 //we should stop audio first for audio mute.
1888 mTvAudio.SwitchAVOutBypass(0);
1889 tv_audio_channel_e audio_channel = mTvin.Tvin_GetInputSourceAudioChannelIndex (SOURCE_MPEG);
1890 mTvAudio.AudioLineInSelectChannel( audio_channel );
1891 mTvAudio.AudioCtlUninit();
1892 //
1893 mTvin.Tvin_StopDecoder();
1894 mTvin.Tvin_RemovePath ( TV_PATH_TYPE_TVIN );
1895 Tv_Set3DMode(VIDEO_3D_MODE_DISABLE);
1896 //double confirm we set the main volume lut buffer to mpeg
1897 RefreshAudioMasterVolume ( SOURCE_MPEG );
1898 mTvAudio.AudioDataInitForDtv();
1899 mTvin.setMpeg2Vdin(1);
1900 mVpp.Tv_LoadVppSettings ( SOURCE_TYPE_DTV, TVIN_SIG_FMT_NULL, INDEX_2D, TVIN_TFMT_2D );
1901 } else {
1902 mTvin.setMpeg2Vdin(0);
1903 mTvin.Tvin_AddPath ( TV_PATH_VDIN_NEW3D_WITHOUTPPMGR_AMVIDEO );
1904 mTvin.VDIN_SetVdinFlag ( MEMP_VDIN_WITHOUT_3D );
1905 }
1906 cur_port = mTvin.Tvin_GetSourcePortBySourceInput ( cur_source_input );
1907 Tv_MiscSetBySource ( source_input );
1908
1909 //only DTV->TVIN or TVIN->DTV need start resource detect thread
1910 if ( ( pre_source_input == SOURCE_DTV || cur_source_input == SOURCE_DTV ) && ( cur_source_input != pre_source_input ) ) {
1911 LOGD ( "%s, dtv need resource detect\n", __FUNCTION__ );
1912 int isNeedCheckD2D3 = ( gTvinConfig.memory512m) ? 1 : 0;
1913 static int sigchkcnt = 0;
1914 while ( true ) {
1915 if ( ( mTvin.Tvin_CheckPathActive ( TV_PATH_TYPE_DEFAULT, isNeedCheckD2D3 ) == TV_PATH_STATUS_INACTIVE )
1916 && ( mTvin.Tvin_CheckPathActive ( TV_PATH_TYPE_TVIN, isNeedCheckD2D3 ) == TV_PATH_STATUS_INACTIVE ) ) {
1917 LOGD("%s, path check is ok, and break\n", __FUNCTION__)
1918 break;
1919 } else {
1920 if (sigchkcnt++ > 20) {
1921 sigchkcnt = 0;
1922 break;
1923 }
1924
1925 LOGW ( "%s,resource is busy.", __FUNCTION__);
1926 }
1927 }//while
1928 }//if need check,and check return
1929
1930 if ( source_input != SOURCE_DTV ) {
1931 // Uninit data
1932 mTvAudio.AudioDataUnInit();
1933 if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3 ||
1934 source_input == SOURCE_MPEG || source_input == SOURCE_DTV ) {
1935 mTvAudio.SwitchAVOutBypass(0);
1936 } else {
1937 mTvAudio.SwitchAVOutBypass(1);
1938 }
1939
1940 tv_audio_channel_e audio_channel = mTvin.Tvin_GetInputSourceAudioChannelIndex (source_input);
1941 mTvAudio.AudioLineInSelectChannel( audio_channel );
1942
1943 Tv_SetAudioInSource ( source_input );
1944 if ( source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3 ) {
1945 m_is_hdmi_sr_detect_start = true;
1946 m_hdmi_sampling_rate = 0;
1947 } else {
1948 mTvAudio.AudioDataInit ( 48000, true );
1949 audio_sr = 48000;
1950 }
1951 //===========================================
1952 if ( mTvin.SwitchPort ( cur_port ) == 0 ) { //ok
1953 //==========================================
1954 SSMSave3DDepth ( 0 );
1955 mTvin.Tvin_SetDepthOf2Dto3D ( 0 ); // set default depth
1956 Tv_Set3DMode(VIDEO_3D_MODE_DISABLE);
1957 SSMSave3DLRSwitch ( 0 );
1958 SSMSave3DTO2D (0);
1959
1960 //for HDMI source connect detect
1961 mTvin.VDIN_OpenHDMIPinMuxOn(true);
1962 mTvAudio.AudioSetRecordDataZero ( false ); //make AudioRecord data avaliable
1963 mVpp.Vpp_ResetLastVppSettingsSourceType();
1964 //==========================================
1965 m_sig_stable_nums = 0;
1966 mSigDetectThread.initSigState();
1967 if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) {
1968 mSigDetectThread.setVdinNoSigCheckKeepTimes(5000, true);
1969 } else {
1970 mSigDetectThread.setVdinNoSigCheckKeepTimes(3000, true);
1971 }
1972 mSigDetectThread.resumeDetect();
1973 } else {
1974 }
1975 }
1976
1977 Tv_SetAudioSourceType(source_input);
1978 RefreshAudioMasterVolume(source_input);
1979 Tv_SetAudioOutputSwap_Type(source_input);
1980
1981 mTvAction = mTvAction & ~ TV_ACTION_SOURCE_SWITCHING;
1982 return 0;
1983}
1984
1985void CTv::onSigToStable()
1986{
1987 if ( ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_TV ) ) {
1988 mSigDetectThread.getCurSigInfo().fmt = m_cur_set_info_fmt;
1989 }
1990 if ( m_autoset_displayfreq) {
1991 if ( CTvin::Tvin_is50HzFrameRateFmt ( mSigDetectThread.getCurSigInfo().fmt ) ) {
1992 mTvin.VDIN_SetDisplayVFreq ( 50, mAv.getVideoDisplayResolution(), mIsFbc );
1993 LOGD ( "%s, SetDisplayVFreq 50HZ.", __FUNCTION__);
1994 } else {
1995 mTvin.VDIN_SetDisplayVFreq ( 60, mAv.getVideoDisplayResolution(), mIsFbc );
1996 LOGD ( "%s, SetDisplayVFreq 60HZ.", __FUNCTION__);
1997 }
1998 }
1999 //showbo mark hdmi auto 3d, tran fmt is 3d, so switch to 3d
2000 LOGD("hdmi trans_fmt = %d", mSigDetectThread.getCurSigInfo().trans_fmt);
2001 if (mSigDetectThread.getCurSigInfo().trans_fmt != TVIN_TFMT_2D) {
2002 Tv_Set3DMode(VIDEO_3D_MODE_AUTO);
2003 }
2004
2005 LOGD("onSigToStable --- trans_fmt = %d", mSigDetectThread.getCurSigInfo().trans_fmt);
2006 //load pq parameters
2007 mVpp.Tv_LoadVppSettings (CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt );
2008
2009 if ( m_win_mode == PREVIEW_WONDOW ) {
2010 mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2);
2011 mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_FULL_STRETCH );
2012 } else {
2013 Vpp_SetDisplayMode ( mVpp.Tv_GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt);
2014 }
2015 m_sig_stable_nums = 0;
2016
2017}
2018void CTv::onSigStableToUnstable()
2019{
2020 LOGD ( "%s, stable to unstable\n", __FUNCTION__);
2021 mTvAudio.SetAudioMuteForTv(CC_AUDIO_MUTE);
2022 mAv.DisableVideoWithBlackColor();
2023 mTvin.Tvin_StopDecoder();
2024}
2025void CTv::onSigStableToUnSupport()
2026{
2027 mTvAudio.SetAudioMuteForTv(CC_AUDIO_MUTE);
2028 mAv.DisableVideoWithBlackColor();
2029 mTvin.Tvin_StopDecoder();
2030
2031 tvin_info_t info = mSigDetectThread.getCurSigInfo();
2032 TvEvent::SignalInfoEvent ev;
2033 ev.mTrans_fmt = info.trans_fmt;
2034 ev.mFmt = info.fmt;
2035 ev.mStatus = info.status;
2036 ev.mReserved = info.reserved;
2037 sendTvEvent ( ev );
2038 LOGD ( "%s, Enable blackscreen for signal change in StableToUnSupport!", __FUNCTION__ );
2039}
2040void CTv::onSigStableToNoSig()
2041{
2042 mTvAudio.SetAudioMuteForTv(CC_AUDIO_MUTE);
2043 mAv.DisableVideoWithBlueColor();
2044 //SetAudioMuteForTv(CC_AUDIO_MUTE);
2045 mTvin.Tvin_StopDecoder();
2046
2047 tvin_info_t info = mSigDetectThread.getCurSigInfo();
2048 TvEvent::SignalInfoEvent ev;
2049 ev.mTrans_fmt = info.trans_fmt;
2050 ev.mFmt = info.fmt;
2051 ev.mStatus = info.status;
2052 ev.mReserved = info.reserved;
2053 sendTvEvent ( ev );
2054 LOGD ( "%s, Enable bluescreen for signal change in StableToNoSig!", __FUNCTION__);
2055}
2056void CTv::onSigUnStableToUnSupport()
2057{
2058 mAv.DisableVideoWithBlackColor();
2059 mTvin.Tvin_StopDecoder();
2060 tvin_info_t info = mSigDetectThread.getCurSigInfo();
2061
2062
2063 TvEvent::SignalInfoEvent ev;
2064 ev.mTrans_fmt = info.trans_fmt;
2065 ev.mFmt = info.fmt;
2066 ev.mStatus = info.status;
2067 ev.mReserved = info.reserved;
2068 sendTvEvent ( ev );
2069 LOGD ( "%s, Enable blackscreen for signal change in UnStableToUnSupport!", __FUNCTION__);
2070}
2071void CTv::onSigUnStableToNoSig()
2072{
2073 mTvAudio.SetAudioMuteForTv(CC_AUDIO_MUTE);
2074 mAv.DisableVideoWithBlueColor();
2075 //SetAudioMuteForTv(CC_AUDIO_MUTE);
2076 mTvin.Tvin_StopDecoder();
2077
2078 tvin_info_t info = mSigDetectThread.getCurSigInfo();
2079 TvEvent::SignalInfoEvent ev;
2080 ev.mTrans_fmt = info.trans_fmt;
2081 ev.mFmt = info.fmt;
2082 ev.mStatus = info.status;
2083 ev.mReserved = info.reserved;
2084 sendTvEvent ( ev );
2085 LOGD ( "%s, Enable bluescreen for signal change in UnStableToNoSig! status = %d", __FUNCTION__, ev.mStatus );
2086}
2087void CTv::onSigNullToNoSig()
2088{
2089 mTvAudio.SetAudioMuteForTv(CC_AUDIO_MUTE);
2090 mAv.DisableVideoWithBlueColor();
2091 //SetAudioMuteForTv(CC_AUDIO_MUTE);
2092 mTvin.Tvin_StopDecoder();
2093
2094 tvin_info_t info = mSigDetectThread.getCurSigInfo();
2095
2096
2097 TvEvent::SignalInfoEvent ev;
2098 ev.mTrans_fmt = info.trans_fmt;
2099 ev.mFmt = info.fmt;
2100 ev.mStatus = info.status;
2101 ev.mReserved = info.reserved;
2102 sendTvEvent ( ev );
2103 LOGD ( "%s, Enable bluescreen for signal change in NullToNoSig!", __FUNCTION__);
2104}
2105
2106void CTv::onSigNoSigToUnstable()
2107{
2108 mAv.DisableVideoWithBlueColor();
2109 LOGD("Enable bluescreen for signal change in NoSigToUnstable\n");
2110}
2111
2112void CTv::onSigStillStable()
2113{
2114 if ( m_sig_stable_nums == 20) {
2115 tvin_info_t info = mSigDetectThread.getCurSigInfo();
2116 TvEvent::SignalInfoEvent ev;
2117 ev.mTrans_fmt = info.trans_fmt;
2118 ev.mFmt = info.fmt;
2119 ev.mStatus = info.status;
2120 ev.mReserved = info.reserved;
2121 sendTvEvent ( ev );
2122 }
2123 if (m_sig_stable_nums == 2) {
2124 int startdec_status = mTvin.Tvin_StartDecoder ( mSigDetectThread.getCurSigInfo() );
2125 if ( startdec_status == 0 ) { //showboz codes from start decode fun
2126 const char *value;
2127 value = config_get_str ( "TV", "tvin.db.reg.en", "null" );
2128 if ( strcmp ( value, "enable" ) == 0 ) {
2129 usleep ( 20 * 1000 );
2130 Tvin_SetPLLValues ();
2131 usleep ( 20 * 1000 );
2132 SetCVD2Values ();
2133 }
2134 }
2135 }
2136 if ( m_sig_stable_nums == 25 ) {
2137 if (!(mTvAction & TV_ACTION_SCANNING))
2138 mTvAudio.SetAudioMuteForTv ( CC_AUDIO_UNMUTE );
2139 mAv.EnableVideoAuto();
2140 }
2141
2142 m_sig_stable_nums++;
2143}
2144void CTv::onSigStillUnstable()
2145{
2146}
2147void CTv::onSigStillNosig()
2148{
2149
2150}
2151void CTv::onSigStillNoSupport()
2152{
2153
2154 tvin_info_t info = mSigDetectThread.getCurSigInfo();
2155 TvEvent::SignalInfoEvent SigEv;
2156 SigEv.mTrans_fmt = info.trans_fmt;
2157 SigEv.mFmt = info.fmt;
2158 SigEv.mStatus = info.status;
2159 SigEv.mReserved = info.reserved;
2160 sendTvEvent ( SigEv );
2161 LOGD ( "%s, Unsupport signal", __FUNCTION__);
2162}
2163void CTv::onSigStillNull()
2164{
2165}
2166void CTv::onStableSigFmtChange()
2167{
2168}
2169void CTv::onStableTransFmtChange()
2170{
2171}
2172void CTv::onSigDetectEnter()
2173{
2174 struct timeval time;
2175 gettimeofday ( &time, NULL );
2176}
2177
2178void CTv::onLoop()
2179{
2180 if ( ( m_is_hdmi_sr_detect_start == true )
2181 && ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) ) {
2182 int sr = mTvin.get_hdmi_sampling_rate();
2183
2184 if ( ( sr > 0 ) && ( sr != m_hdmi_sampling_rate ) ) {
2185 if ( 0 == m_hdmi_sampling_rate ) {
2186 LOGD ( "%s, Init HDMI audio, sampling rate:%d", __FUNCTION__, sr );
2187 mTvAudio.AudioDataInit ( sr, false );
2188 audio_sr = sr;
2189 } else {
2190 LOGD ( "%s, Reset HDMI sampling rate to %d", __FUNCTION__, sr );
2191 mTvAudio.AudioChangeSampleRate ( sr );
2192 }
2193
2194 m_hdmi_sampling_rate = sr;
2195 }
2196 }
2197}
2198
2199void CTv::onSourceConnect(int source_type, int connect_status)
2200{
2201 TvEvent::SourceConnectEvent ev;
2202 ev.mSourceInput = source_type;
2203 ev.connectionState = connect_status;
2204 sendTvEvent(ev);
2205}
2206
2207int CTv::GetSourceConnectStatus(int source_input)
2208{
2209 return mSourceConnectDetectThread.GetSourceConnectStatus(source_input);
2210}
2211
2212tv_source_input_t CTv::GetCurrentSourceInputLock ( void )
2213{
2214 Mutex::Autolock _l ( mLock );
2215 return m_source_input;
2216}
2217
2218//dtv and tvin
2219tvin_info_t CTv::GetCurrentSignalInfo ( void )
2220{
2221 tvin_trans_fmt det_fmt = TVIN_TFMT_2D;
2222 tvin_sig_status_t signalState = TVIN_SIG_STATUS_NULL;
2223 tvin_info_t signal_info = mSigDetectThread.getCurSigInfo();
2224
2225 if ( (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_DTV ) ) {
2226 for ( int i = 0; i < 10; i++ ) {
2227 det_fmt = mTvin.TvinApi_Get3DDectMode();
2228 signal_info.status = TVIN_SIG_STATUS_STABLE;
2229
2230 if ( det_fmt != TVIN_TFMT_2D ) {
2231 signal_info.trans_fmt = det_fmt;
2232 break;
2233 }
2234 }
2235 }
2236 return signal_info;
2237}
2238
2239int CTv::Tv_Set3DMode ( VIDEO_3D_MODE_T mode )
2240{
2241 if (mode == VIDEO_3D_MODE_AUTO) {
2242 mTvin.VDIN_SetDI3DDetc (1);
2243 } else {
2244 mTvin.VDIN_SetDI3DDetc (0);
2245 }
2246
2247 mAv.set3DMode(mode, 0, 0);
2248 m_mode_3d = mode;
2249 SSMSave3DMode ( ( unsigned char ) mode );
2250 SetBypassModulesFor3D ( mode );
2251 return 0;
2252}
2253
2254VIDEO_3D_MODE_T CTv::Tv_Get3DMode ( void )
2255{
2256 return m_mode_3d;
2257}
2258
2259int CTv::Tv_Set3DLRSwith ( int on_off)
2260{
2261 LOGW ( "%s,Set3D LRSwith on_off %d ,status %d !!! ", __FUNCTION__, on_off);
2262 mAv.set3DMode(m_mode_3d, on_off, 0);
2263 SSMSave3DLRSwitch(on_off);
2264 return 0;
2265}
2266
2267int CTv::Tv_Get3DLRSwith ( void )
2268{
2269 unsigned char val = 0;
2270 SSMRead3DLRSwitch ( &val );
2271 return ( int ) val;
2272}
2273
2274int CTv::Tv_Set3DTo2DMode ( int mode)
2275{
2276 LOGW ( "%s,Set3D to 2D mode %d ,status %d !!! ", __FUNCTION__ , mode);
2277 mAv.set3DMode(m_mode_3d, 0, mode);
2278 SSMSave3DTO2D ( mode );
2279 return 0;
2280}
2281
2282int CTv::Tv_Get3DTo2DMode ( void )
2283{
2284 unsigned char val = 0;
2285 SSMRead3DTO2D ( &val );
2286 return val;
2287}
2288
2289int CTv::Tv_Set3DDepth ( int value )
2290{
2291 mTvin.Tvin_SetDepthOf2Dto3D( value );
2292 SSMSave3DDepth ( value );
2293 return 0;
2294}
2295
2296int CTv::GetSave3DDepth ( void )
2297{
2298 unsigned char val = 0;
2299 SSMRead3DDepth ( &val );
2300 return val;
2301}
2302
2303is_3d_type_t CTv::Check2Dor3D ( VIDEO_3D_MODE_T mode3d, tvin_trans_fmt_t trans_fmt )
2304{
2305 if ( mode3d == VIDEO_3D_MODE_DISABLE ) {
2306 return INDEX_2D;
2307 } else if ( mode3d == VIDEO_3D_MODE_AUTO ) {
2308 if ( trans_fmt == TVIN_TFMT_2D ) {
2309 return INDEX_2D;
2310 } else {
2311 return INDEX_3D;
2312 }
2313 } else {
2314 return INDEX_3D;
2315 }
2316}
2317
2318
2319int CTv::Tvin_SetPLLValues ()
2320{
2321 tvin_sig_fmt_t sig_fmt = mSigDetectThread.getCurSigInfo().fmt;
2322 tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceInput(m_source_input);
2323 am_regs_t regs;
2324
2325 if ( mVpp.getPqData()->PQ_GetPLLParams ( source_port, sig_fmt, &regs ) == 0 ) {
2326 LOGD ("%s,PQ_GetPLLParams(source_port[%d], sig_fmt[%d],&regs).\n", __FUNCTION__, source_port, sig_fmt );
2327
2328 if ( mTvin.TvinApi_LoadPLLValues ( regs ) < 0 ) {
2329 LOGE ( "%s, TvinApi_LoadPLLValues failed!\n", __FUNCTION__ );
2330 return -1;
2331 }
2332 } else {
2333 LOGE ( "%s, PQ_GetPLLParams failed!\n", __FUNCTION__ );
2334 return -1;
2335 }
2336
2337 return 0;
2338}
2339int CTv::SetCVD2Values ()
2340{
2341 tvin_sig_fmt_t sig_fmt = mSigDetectThread.getCurSigInfo().fmt;
2342 tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceInput(m_source_input);
2343 am_regs_t regs;
2344
2345 if (mVpp.getPqData()->PQ_GetCVD2Params ( source_port, sig_fmt, &regs ) == 0) {
2346 LOGD ( "%s, PQ_GetCVD2Params(source_port[%d], sig_fmt[%d],&regs).\n", __FUNCTION__,
2347 source_port, sig_fmt );
2348
2349 if ( mTvin.TvinApi_LoadCVD2Values ( regs ) < 0 ) {
2350 LOGE ( "%s, TvinApi_LoadCVD2Values failed!\n", __FUNCTION__);
2351 return -1;
2352 }
2353 } else {
2354 LOGE ( "%s, PQ_GetCVD2Params failed!\n", __FUNCTION__);
2355 return -1;
2356 }
2357
2358 return 0;
2359}
2360
2361int CTv::SetPreviewWindow ( tvin_window_pos_t pos )
2362{
2363 m_win_pos.x1 = pos.x1;
2364 m_win_pos.y1 = pos.y1;
2365 m_win_pos.x2 = pos.x2;
2366 m_win_pos.y2 = pos.y2;
2367 LOGD ( "%s, SetPreviewWindow x = %d y=%d", __FUNCTION__, pos.x2, pos.y2 );
2368
2369 tvin_window_pos_t def_pos;
2370 Vpp_GetDisplayResolutionInfo(&def_pos);
2371
2372 if (pos.x1 != 0 || pos.y1 != 0 || pos.x2 != def_pos.x2 || pos.y2 != def_pos.y2) {
2373 m_win_mode = PREVIEW_WONDOW;
2374 } else {
2375 m_win_mode = NORMAL_WONDOW;
2376 }
2377
2378 return mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2);;
2379}
2380
2381/*********************** Audio start **********************/
2382int CTv::SetAudioVolDigitLUTBuf ( tv_source_input_t source_input )
2383{
2384 if (source_input == SOURCE_TV) {
2385 mTvAudio.AudioSetVolumeDigitLUTBuf ( CC_LUT_SEL_TV, 1, 1, -1 );
2386 } else if (source_input == SOURCE_AV1 || source_input == SOURCE_AV2) {
2387 mTvAudio.AudioSetVolumeDigitLUTBuf ( CC_LUT_SEL_AV, 1, 1, -1 );
2388 } else if (source_input == SOURCE_YPBPR1 || source_input == SOURCE_YPBPR2) {
2389 mTvAudio.AudioSetVolumeDigitLUTBuf ( CC_LUT_SEL_COMP, 1, 1, -1 );
2390 } else if (source_input == SOURCE_VGA) {
2391 mTvAudio.AudioSetVolumeDigitLUTBuf ( CC_LUT_SEL_VGA, 1, 1, -1 );
2392 } else if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) {
2393 mTvAudio.AudioSetVolumeDigitLUTBuf ( CC_LUT_SEL_HDMI, 1, 1, -1 );
2394 } else if ( source_input == SOURCE_MPEG ) {
2395 mTvAudio.AudioSetVolumeDigitLUTBuf ( CC_LUT_SEL_MPEG, 1, 1, -1 );
2396 } else if ( source_input == SOURCE_DTV ) {
2397 mTvAudio.AudioSetVolumeDigitLUTBuf ( CC_LUT_SEL_MPEG, 1, 1, -1 );
2398 }
2399 return 0;
2400}
2401
2402void CTv::RefreshAudioMasterVolume ( tv_source_input_t source_input )
2403{
2404 if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) {
2405 if ( GetAudioDVISupportEnable() == 1 ) {
2406 if ( IsDVISignal() ) {
2407 SetAudioVolDigitLUTBuf ( SOURCE_MPEG );
2408 mTvAudio.SetAudioMasterVolume ( mTvAudio.GetAudioMasterVolume() );
2409 return;
2410 }
2411 }
2412 }
2413
2414 SetAudioVolDigitLUTBuf ( source_input );
2415 mTvAudio.SetAudioMasterVolume ( mTvAudio.GetAudioMasterVolume() );
2416}
2417
2418int CTv::Tv_SetAudioInSource (tv_source_input_t source_input)
2419{
2420 if (source_input == SOURCE_TV) {
2421 if (mTvin.Tvin_GetAudioInSourceType(source_input) == TV_AUDIO_IN_SOURCE_TYPE_ATV) {
2422 return mTvAudio.AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_ATV);
2423 } else {
2424 return mTvAudio.AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_LINEIN);
2425 }
2426 } else if (source_input == SOURCE_AV1 || source_input == SOURCE_AV2) {
2427 return mTvAudio.AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_LINEIN);
2428 } else if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) {
2429 return mTvAudio.AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_HDMI);
2430 } else if (source_input == SOURCE_YPBPR1 || source_input == SOURCE_YPBPR2 ||
2431 source_input == SOURCE_TYPE_VGA) {
2432 return mTvAudio.AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_LINEIN);
2433 }
2434
2435 return 0;
2436}
2437
2438int CTv::Tv_SetAudioSourceType (tv_source_input_t source_input)
2439{
2440 int audio_source = -1;
2441
2442 if (source_input == SOURCE_TV) {
2443 audio_source = AUDIO_ATV_SOURCE;
2444 } else if (source_input == SOURCE_AV1 || source_input == SOURCE_AV2) {
2445 audio_source = AUDIO_AV_SOURCE;
2446 } else if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) {
2447 audio_source = AUDIO_HDMI_SOURCE;
2448 } else if (source_input == SOURCE_YPBPR1 || source_input == SOURCE_YPBPR2 ||
2449 source_input == SOURCE_TYPE_VGA) {
2450 audio_source = AUDIO_AV_SOURCE;
2451 } else if (source_input == SOURCE_DTV) {
2452 audio_source = AUDIO_MPEG_SOURCE;
2453 } else {
2454 audio_source = AUDIO_MPEG_SOURCE;
2455 }
2456
2457 return mTvAudio.AudioSetAudioSourceType(audio_source);
2458}
2459void CTv::Tv_SetAudioOutputSwap_Type (tv_source_input_t source_input)
2460{
2461 const char *config_value;
2462 config_value = config_get_str("TV", "audio.output.swap.enable", "null");
2463 if ( strcmp ( config_value, "enable" ) == 0 ) {
2464 int sw_status = 0;
2465
2466 LOGD("%s, audio.output.swap.enable\n", __FUNCTION__);
2467
2468 switch (source_input) {
2469 case SOURCE_AV1:
2470 config_value = config_get_str("TV", "audio.output.swap.av1", "null");
2471 sw_status = atoi ( config_value );
2472 mTvAudio.SetOutput_Swap(sw_status);
2473 LOGD("%s, av1 %d\n", __FUNCTION__, sw_status);
2474 break;
2475 case SOURCE_AV2:
2476 config_value = config_get_str("TV", "audio.output.swap.av2", "null");
2477 sw_status = atoi ( config_value );
2478 mTvAudio.SetOutput_Swap(sw_status);
2479 LOGD("%s, av2 %d\n", __FUNCTION__, sw_status);
2480 break;
2481 case SOURCE_HDMI1:
2482 config_value = config_get_str("TV", "audio.output.swap.hdmi1", "null");
2483 sw_status = atoi ( config_value );
2484 mTvAudio.SetOutput_Swap(sw_status);
2485 LOGD("%s, hdmi1 %d\n", __FUNCTION__, sw_status);
2486 break;
2487 case SOURCE_HDMI2:
2488 config_value = config_get_str("TV", "audio.output.swap.hdmi2", "null");
2489 sw_status = atoi ( config_value );
2490 mTvAudio.SetOutput_Swap(sw_status);
2491 LOGD("%s, hdmi2 %d\n", __FUNCTION__, sw_status);
2492 break;
2493 case SOURCE_HDMI3:
2494 config_value = config_get_str("TV", "audio.output.swap.hdmi3", "null");
2495 sw_status = atoi ( config_value );
2496 mTvAudio.SetOutput_Swap(sw_status);
2497 LOGD("%s, hdmi3 %d\n", __FUNCTION__, sw_status);
2498 break;
2499 case SOURCE_TV:
2500 config_value = config_get_str("TV", "audio.output.swap.tv", "null");
2501 sw_status = atoi ( config_value );
2502 mTvAudio.SetOutput_Swap(sw_status);
2503 LOGD("%s, tv %d\n", __FUNCTION__, sw_status);
2504 break;
2505 case SOURCE_DTV:
2506 config_value = config_get_str("TV", "audio.output.swap.dtv", "null");
2507 sw_status = atoi ( config_value );
2508 mTvAudio.SetOutput_Swap(sw_status);
2509 LOGD("%s, dtv %d\n", __FUNCTION__, sw_status);
2510 break;
2511 case SOURCE_MPEG:
2512 config_value = config_get_str("TV", "audio.output.swap.mpeg", "null");
2513 sw_status = atoi ( config_value );
2514 mTvAudio.SetOutput_Swap(sw_status);
2515 LOGD("%s, mpeg %d\n", __FUNCTION__, sw_status);
2516 break;
2517 default:
2518 mTvAudio.SetOutput_Swap(sw_status);
2519 LOGD("%s, default %d\n", __FUNCTION__, sw_status);
2520 break;
2521 }
2522 }
2523
2524}
2525
2526/*********************** Audio end **********************/
2527
2528unsigned int CTv::Vpp_GetDisplayResolutionInfo(tvin_window_pos_t *win_pos)
2529{
2530 int display_resolution = mAv.getVideoDisplayResolution();
2531 unsigned int tmp_ret = 0;
2532
2533 switch (display_resolution) {
2534 case VPP_DISPLAY_RESOLUTION_1366X768:
2535 tmp_ret |= (CC_RESOLUTION_1366X768_W << 16);
2536 tmp_ret |= (CC_RESOLUTION_1366X768_H << 0);
2537 break;
2538 case VPP_DISPLAY_RESOLUTION_1920X1080:
2539 tmp_ret |= (CC_RESOLUTION_1920X1080_W << 16);
2540 tmp_ret |= (CC_RESOLUTION_1920X1080_H << 0);
2541 break;
2542 case VPP_DISPLAY_RESOLUTION_3840X2160:
2543 tmp_ret |= (CC_RESOLUTION_3840X2160_W << 16);
2544 tmp_ret |= (CC_RESOLUTION_3840X2160_H << 0);
2545 break;
2546 default:
2547 tmp_ret |= (CC_RESOLUTION_3840X2160_W << 16);
2548 tmp_ret |= (CC_RESOLUTION_3840X2160_H << 0);
2549 break;
2550 }
2551
2552 if (win_pos != NULL) {
2553 win_pos->x1 = 0;
2554 win_pos->y1 = 0;
2555 win_pos->x2 = ((tmp_ret >> 16) & 0xFFFF) - 1;
2556 win_pos->y2 = ((tmp_ret >> 0) & 0xFFFF) - 1;
2557 }
2558
2559 return 0;
2560}
2561
2562
2563int CTv::setBlackoutEnable(int enable)
2564{
2565 m_blackout_enable = enable;
2566 return SSMSaveBlackoutEnable(enable);
2567}
2568
2569int CTv::getSaveBlackoutEnable()
2570{
2571 int8_t enable;
2572 SSMReadBlackoutEnable(&enable);
2573 return enable;
2574}
2575void CTv::startAutoBackLight()
2576{
2577 mAutoBackLight.startAutoBacklight(CTvin::Tvin_SourceInputToSourceInputType(m_source_input));
2578}
2579
2580void CTv::stopAutoBackLight()
2581{
2582 mAutoBackLight.stopAutoBacklight();
2583}
2584
2585int CTv::getAutoBackLight_on_off()
2586{
2587 return mAutoBackLight.isAutoBacklightOn() ? 1 : 0;
2588}
2589/*********************** SSM start **********************/
2590int CTv::Tv_SSMRestoreDefaultSetting()
2591{
2592 SSMRestoreDeviceMarkValues();
2593 mTvAudio.AudioSSMRestoreDefaultSetting();
2594 mVpp.VPPSSMRestoreDefault();
2595 MiscSSMRestoreDefault();
2596 ReservedSSMRestoreDefault();
2597 SSMSaveCVBSStd ( 0 );
2598 SSMSaveLastSelectSourceInput ( SOURCE_TV );
2599 SSMSavePanelType ( 0 );
2600 //tvconfig default
2601 saveDTVProgramID ( -1 );
2602 saveATVProgramID ( -1 );
2603 return 0;
2604}
2605
2606int CTv::clearDbAllProgramInfoTable()
2607{
2608 return CTvDatabase::GetTvDb()->clearDbAllProgramInfoTable();
2609}
2610
2611int CTv::Tv_SSMFacRestoreDefaultSetting()
2612{
2613 mVpp.VPPSSMFacRestoreDefault();
2614 mTvAudio.AudioSSMRestoreDefaultSetting();
2615 MiscSSMFacRestoreDefault();
2616
2617 return 0;
2618}
2619/*********************** SSM End **********************/
2620//not in CTv, not use lock
2621void CTv::setSourceSwitchAndPlay()
2622{
2623 int progID = 0;
2624 LOGD ( "%s\n", __FUNCTION__ );
2625 static const int POWERON_SOURCE_TYPE_NONE = 0;//not play source
2626 static const int POWERON_SOURCE_TYPE_LAST = 1;//play last save source
2627 static const int POWERON_SOURCE_TYPE_SETTING = 2;//play ui set source
2628 int to_play_source = -1;
2629 int powerup_type = SSMReadPowerOnOffChannel();
2630 LOGD("read power on source type = %d", powerup_type);
2631 if (powerup_type == POWERON_SOURCE_TYPE_NONE) {
2632 return ;
2633 } else if (powerup_type == POWERON_SOURCE_TYPE_LAST) {
2634 to_play_source = SSMReadSourceInput();
2635 } else if (powerup_type == POWERON_SOURCE_TYPE_SETTING) {
2636 to_play_source = SSMReadLastSelectSourceInput();
2637 }
2638 SetSourceSwitchInput (( tv_source_input_t ) to_play_source );
2639 if ( to_play_source == SOURCE_TV ) {
2640 progID = getATVProgramID();
2641 } else if ( to_play_source == SOURCE_DTV ) {
2642 progID = getDTVProgramID();
2643 }
2644 playProgramLock(progID);
2645 return;
2646}
2647
2648int CTv::startCC(int country, int src, int channel, int service)
2649{
2650 //turn_on_cc = true;
2651 return mTvSub.sub_start_atsc_cc((enum cc_param_country)country, (enum cc_param_source_type)src, channel, (enum cc_param_caption_type)service);
2652}
2653
2654int CTv::stopCC()
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