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