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