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