blob: f3c8764056009e1771dd1a84ff43d9dba31d3058
1 | // |
2 | // |
3 | // amlogic 2013 |
4 | // |
5 | // @ Project : tv |
6 | // @ File Name : CTv.cpp |
7 | // @ Date : 2013-11 |
8 | // @ Author : |
9 | #include <stdio.h> |
10 | #include <unistd.h> |
11 | #include <fcntl.h> |
12 | #include <dirent.h> |
13 | #include <am_epg.h> |
14 | #include <am_mem.h> |
15 | #include "CTvDatabase.h" |
16 | #include <stdlib.h> |
17 | #include <string.h> |
18 | #include <malloc.h> |
19 | #include <pthread.h> |
20 | #include <sys/types.h> |
21 | #include <errno.h> |
22 | #include <dlfcn.h> |
23 | #include <cutils/properties.h> |
24 | #include <cutils/log.h> |
25 | #include <cutils/android_reboot.h> |
26 | #include <utils/threads.h> |
27 | #include <time.h> |
28 | #include <sys/prctl.h> |
29 | #include <getopt.h> |
30 | #include <errno.h> |
31 | #include <sys/types.h> |
32 | #include <sys/stat.h> |
33 | #include <fcntl.h> |
34 | #include <stdlib.h> |
35 | #ifdef ANDROID |
36 | #include <termios.h> |
37 | #endif |
38 | #include <string.h> |
39 | #include <signal.h> |
40 | |
41 | #include "../version/version.h" |
42 | #include "../tvsetting/CTvSetting.h" |
43 | #include "../tvutils/tvutils.h" |
44 | #include "../tvconfig/tvconfig.h" |
45 | #include "../tvutils/CFile.h" |
46 | #include <hardware_legacy/power.h> |
47 | #include "../tvutils/serial_operate.h" |
48 | #include <xxxconfig.h> |
49 | |
50 | extern "C" { |
51 | #include "am_ver.h" |
52 | #include "am_misc.h" |
53 | #include "am_debug.h" |
54 | #include "am_fend.h" |
55 | } |
56 | |
57 | #include <math.h> |
58 | #include <sys/ioctl.h> |
59 | |
60 | #include "CTv.h" |
61 | |
62 | #define LOG_TAG "CTv" |
63 | |
64 | |
65 | using namespace android; |
66 | |
67 | // Called each time a message is logged. |
68 | static void sqliteLogCallback(void *data, int iErrCode, const char *zMsg) |
69 | { |
70 | data = data; |
71 | LOGD( "showbo sqlite (%d) %s\n", iErrCode, zMsg); |
72 | } |
73 | |
74 | CTv::CTv() : |
75 | mSigDetectThread(&mTvin), |
76 | mSourceConnectDetectThread(&mTvin), |
77 | mHDMIRxCEC ( &mTvin ), |
78 | mTvScanner ( &mTvin ), |
79 | mTvMsgQueue(this), |
80 | mAutoBackLight( &mVpp, &mTvin ), |
81 | mTvScannerDetectObserver(this), |
82 | mAutoPQparam( &mVpp, &mTvin, &mAv ) |
83 | { |
84 | mAudioMuteStatusForTv = CC_AUDIO_UNMUTE; |
85 | mAudioMuteStatusForSystem = CC_AUDIO_UNMUTE; |
86 | //mpClient = pClient; |
87 | //copy file to param |
88 | if (Tv_Utils_IsFileExist ( TV_CONFIG_FILE_SYSTEM_PATH )) { |
89 | if (!Tv_Utils_IsFileExist ( TV_CONFIG_FILE_PARAM_PATH )) { |
90 | CFile file ( TV_CONFIG_FILE_SYSTEM_PATH ); |
91 | |
92 | if ( file.copyTo ( TV_CONFIG_FILE_PARAM_PATH ) != 0 ) { |
93 | LOGE ( "%s, copy file = %s , error", __FUNCTION__, TV_CONFIG_FILE_PARAM_PATH ); |
94 | } |
95 | } |
96 | } |
97 | |
98 | if (Tv_Utils_IsFileExist ( TV_CHANNEL_LIST_SYSTEM_PATH )) { |
99 | if (!Tv_Utils_IsFileExist ( TV_CHANNEL_LIST_PARAM_PATH )) { |
100 | CFile file ( TV_CHANNEL_LIST_SYSTEM_PATH ); |
101 | |
102 | if ( file.copyTo ( TV_CHANNEL_LIST_PARAM_PATH ) != 0 ) { |
103 | LOGE ( "%s, copy file = %s , error", __FUNCTION__, TV_CHANNEL_LIST_PARAM_PATH ); |
104 | } |
105 | } |
106 | } |
107 | |
108 | //ssm |
109 | if (Tv_Utils_IsFileExist ( TV_SSM_DATA_SYSTEM_PATH )) { |
110 | if (!Tv_Utils_IsFileExist ( TV_SSM_DATA_PARAM_PATH )) { |
111 | CFile file ( TV_SSM_DATA_SYSTEM_PATH ); |
112 | |
113 | if ( file.copyTo ( TV_SSM_DATA_PARAM_PATH ) != 0 ) { |
114 | LOGE ( "%s, copy file = %s , error", __FUNCTION__, TV_SSM_DATA_PARAM_PATH ); |
115 | } |
116 | } |
117 | } |
118 | |
119 | AM_EVT_Init(); |
120 | //mTvEpg.setObserver ( &mTvMsgQueue ); |
121 | mpObserver = NULL; |
122 | fbcIns = NULL; |
123 | dtv_auto_3d_flag = 0; |
124 | mAutoSetDisplayFreq = false; |
125 | |
126 | tv_config_load ( TV_CONFIG_FILE_PATH ); |
127 | sqlite3_config (SQLITE_CONFIG_SERIALIZED); |
128 | //sqlite3_config(SQLITE_CONFIG_LOG, &sqliteLogCallback, (void*)1); |
129 | sqlite3_soft_heap_limit(8 * 1024 * 1024); |
130 | // Initialize SQLite. |
131 | sqlite3_initialize(); |
132 | CTvDatabase::GetTvDb()->InitTvDb ( TV_DB_PATH ); |
133 | |
134 | if ( CTvDimension::isDimensionTblExist() == false ) { |
135 | CTvDimension::builtinAtscDimensions(); |
136 | } |
137 | |
138 | CTvSettingLoad(); |
139 | |
140 | mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL; |
141 | if (hdmiOutWithFbc()) { |
142 | mHdmiOutFbc = true; |
143 | } else { |
144 | mHdmiOutFbc = false; |
145 | } |
146 | |
147 | m_sig_stable_nums = 0; |
148 | mSetHdmiEdid = false; |
149 | m_cur_playing_prog_id = -1; |
150 | |
151 | m_hdmi_audio_data = 0; |
152 | mSigDetectThread.setObserver ( this ); |
153 | mSourceConnectDetectThread.setObserver ( this ); |
154 | mHDMIRxCEC.setObserver(this); |
155 | mFrontDev.setObserver ( &mTvMsgQueue ); |
156 | mpUpgradeFBC = NULL; |
157 | if (mHdmiOutFbc) { |
158 | fbcIns = GetSingletonFBC(); |
159 | |
160 | mpUpgradeFBC = new CUpgradeFBC(); |
161 | mpUpgradeFBC->setObserver(this); |
162 | } |
163 | mSerialA.setObserver(this); |
164 | mSerialB.setObserver(this); |
165 | mSerialC.setObserver(this); |
166 | mSubtitle.setObserver(this); |
167 | mHeadSet.setObserver(this); |
168 | mTvScanner.setGlobalScanerObject(&mTvScanner); |
169 | mAv.setObserver(&mTvMsgQueue); |
170 | mMainVolLutTableExtraName[0] = '\0'; |
171 | //----------------------------------------------------------- |
172 | mCurAudioMasterVolume = CC_DEF_SOUND_VOL; |
173 | mCurAudioBalance = CC_DEF_SOUND_BALANCE_VAL; |
174 | mCurAudioSupperBassVolume = CC_DEF_SUPPERBASS_VOL; |
175 | mCurAudioSupperBassSwitch = CC_SWITCH_OFF; |
176 | mCurAudioSRSSurround = CC_SWITCH_OFF; |
177 | mCurAudioSrsDialogClarity = CC_SWITCH_OFF; |
178 | mCurAudioSrsTruBass = CC_SWITCH_OFF; |
179 | mCurAudioSPDIFSwitch = CC_SWITCH_ON; |
180 | mCurAudioSPDIFMode = CC_SPDIF_MODE_PCM; |
181 | mCurAudioBassVolume = CC_DEF_BASS_TREBLE_VOL; |
182 | mCurAudioTrebleVolume = CC_DEF_BASS_TREBLE_VOL; |
183 | mCurAudioSoundMode = CC_SOUND_MODE_END; |
184 | mCurAudioWallEffect = CC_SWITCH_OFF; |
185 | mCurAudioEQMode = CC_EQ_MODE_START; |
186 | mCustomAudioMasterVolume = CC_DEF_SOUND_VOL; |
187 | mCustomAudioBalance = CC_DEF_SOUND_BALANCE_VAL; |
188 | mCustomAudioSupperBassVolume = CC_DEF_SUPPERBASS_VOL; |
189 | mCustomAudioSupperBassSwitch = CC_SWITCH_OFF; |
190 | mCustomAudioSRSSurround = CC_SWITCH_OFF; |
191 | mCustomAudioSrsDialogClarity = CC_SWITCH_OFF; |
192 | mCustomAudioSrsTruBass = CC_SWITCH_OFF; |
193 | mCustomAudioBassVolume = CC_DEF_BASS_TREBLE_VOL; |
194 | mCustomAudioTrebleVolume = CC_DEF_BASS_TREBLE_VOL; |
195 | mCustomAudioSoundMode = CC_SOUND_MODE_END; |
196 | mCustomAudioWallEffect = CC_SWITCH_OFF; |
197 | mCustomAudioEQMode = CC_EQ_MODE_START; |
198 | mCustomAudioSoundEnhancementSwitch = CC_SWITCH_OFF; |
199 | mVolumeCompensationVal = 0; |
200 | |
201 | mMainVolumeBalanceVal = 0; |
202 | for (int i = 0; i < CC_BAND_ITEM_CNT; i++) { |
203 | mCustomEQGainBuf[i] = 0; |
204 | mCurEQGainBuf[i] = 0; |
205 | mCurEQGainChBuf[i] = 0; |
206 | } |
207 | static const int WALL_EFFECT_VALUE[CC_BAND_ITEM_CNT] = { 0, 0, 1, 2, 2, 0 }; |
208 | for (int i = 0; i < CC_BAND_ITEM_CNT; i++) { |
209 | mWallEffectValueBuf[i] = WALL_EFFECT_VALUE[i]; |
210 | } |
211 | mTvAction &= TV_ACTION_NULL; |
212 | mTvStatus = TV_INIT_ED; |
213 | print_version_info(); |
214 | }; |
215 | |
216 | CTv::~CTv() |
217 | { |
218 | mpObserver = NULL; |
219 | CTvSettingunLoad(); |
220 | CTvDatabase::deleteTvDb(); |
221 | tv_config_unload(); |
222 | mAv.Close(); |
223 | mTvStatus = TV_INIT_ED; |
224 | mFrontDev.Close(); |
225 | |
226 | if (mpUpgradeFBC != NULL) { |
227 | delete mpUpgradeFBC; |
228 | mpUpgradeFBC = NULL; |
229 | } |
230 | } |
231 | |
232 | void CTv::onEvent ( const CTvScanner::ScannerEvent &ev ) |
233 | { |
234 | LOGD ( "%s, CTv::onEvent lockStatus = %d type = %d\n", __FUNCTION__, ev.mLockedStatus, ev.mType ); |
235 | |
236 | if ( mDtvScanRunningStatus == DTV_SCAN_RUNNING_ANALYZE_CHANNEL ) { |
237 | if ( ev.mType == CTvScanner::ScannerEvent::EVENT_SCAN_END ) { |
238 | CMessage msg; |
239 | msg.mType = CTvMsgQueue::TV_MSG_STOP_ANALYZE_TS; |
240 | msg.mpData = this; |
241 | mTvMsgQueue.sendMsg ( msg ); |
242 | } else if ( ev.mType == CTvScanner::ScannerEvent::EVENT_STORE_END ) { |
243 | CTvEpg::EpgEvent epgev; |
244 | epgev.type = CTvEpg::EpgEvent::EVENT_CHANNEL_UPDATE_END; |
245 | mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL; |
246 | sendTvEvent ( epgev ); |
247 | } |
248 | } else { |
249 | sendTvEvent ( ev ); |
250 | } |
251 | } |
252 | |
253 | void CTv::onEvent ( const CFrontEnd::FEEvent &ev ) |
254 | { |
255 | const char *config_value = NULL; |
256 | LOGD ( "%s, FE event type = %d tvaction=%x", __FUNCTION__, ev.mCurSigStaus, mTvAction); |
257 | if (mTvAction & TV_ACTION_SCANNING) return; |
258 | |
259 | //前端事件响应处理 |
260 | if ( ev.mCurSigStaus == CFrontEnd::FEEvent::EVENT_FE_HAS_SIG ) { //作为信号稳定 |
261 | 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 |
262 | if ( m_win_mode == PREVIEW_WONDOW ) { |
263 | //mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2); |
264 | mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_FULL_STRETCH ); |
265 | } |
266 | |
267 | if ( mAutoSetDisplayFreq) { |
268 | mTvin.VDIN_SetDisplayVFreq ( 50, mAv.getVideoDisplayResolution() , mHdmiOutFbc); |
269 | } |
270 | TvEvent::SignalInfoEvent ev; |
271 | ev.mStatus = TVIN_SIG_STATUS_STABLE; |
272 | ev.mTrans_fmt = TVIN_TFMT_2D; |
273 | ev.mFmt = TVIN_SIG_FMT_NULL; |
274 | ev.mReserved = 0; |
275 | sendTvEvent ( ev ); |
276 | //if (mAv.WaittingVideoPlaying() == 0) { |
277 | SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mAv.getVideoResolutionToFmt()); |
278 | usleep(50 * 1000); |
279 | mAv.EnableVideoNow(); |
280 | SetAudioMuteForTv ( CC_AUDIO_UNMUTE ); |
281 | //} |
282 | Tv_SetAudioInSource(SOURCE_DTV); |
283 | } |
284 | } else if ( ev.mCurSigStaus == CFrontEnd::FEEvent::EVENT_FE_NO_SIG ) { //作为信号消失 |
285 | if (/*m_source_input == SOURCE_TV || */m_source_input == SOURCE_DTV && (mTvAction & TV_ACTION_PLAYING)) { //just playing |
286 | config_value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); |
287 | if ( strcmp ( config_value, "black" ) == 0 ) { |
288 | mAv.DisableVideoWithBlackColor(); |
289 | } else { |
290 | mAv.DisableVideoWithBlueColor(); |
291 | } |
292 | SetAudioMuteForTv ( CC_AUDIO_MUTE ); |
293 | |
294 | TvEvent::SignalInfoEvent ev; |
295 | ev.mStatus = TVIN_SIG_STATUS_NOSIG; |
296 | ev.mTrans_fmt = TVIN_TFMT_2D; |
297 | ev.mFmt = TVIN_SIG_FMT_NULL; |
298 | ev.mReserved = 0; |
299 | sendTvEvent ( ev ); |
300 | } |
301 | } |
302 | } |
303 | |
304 | void CTv::onEvent ( const CTvEpg::EpgEvent &ev ) |
305 | { |
306 | switch ( ev.type ) { |
307 | case CTvEpg::EpgEvent::EVENT_TDT_END: |
308 | LOGD ( "%s, CTv::onEvent epg time = %ld", __FUNCTION__, ev.time ); |
309 | mTvTime.setTime ( ev.time ); |
310 | break; |
311 | |
312 | case CTvEpg::EpgEvent::EVENT_CHANNEL_UPDATE: { |
313 | LOGD ( "%s, CTv:: onEvent channel update", __FUNCTION__ ); |
314 | CMessage msg; |
315 | msg.mType = CTvMsgQueue::TV_MSG_START_ANALYZE_TS; |
316 | msg.mpData = this; |
317 | mCurAnalyzeTsChannelID = ev.channelID; |
318 | mTvMsgQueue.sendMsg ( msg ); |
319 | break; |
320 | } |
321 | |
322 | default: |
323 | break; |
324 | } |
325 | |
326 | sendTvEvent ( ev ); |
327 | } |
328 | |
329 | void CTv::onEvent(const CAv::AVEvent &ev) |
330 | { |
331 | const char *config_value = NULL; |
332 | LOGD("AVEvent = %d", ev.type); |
333 | switch ( ev.type ) { |
334 | case CAv::AVEvent::EVENT_AV_STOP: { |
335 | config_value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); |
336 | if ( strcmp ( config_value, "black" ) == 0 ) { |
337 | mAv.DisableVideoWithBlackColor(); |
338 | } else { |
339 | mAv.DisableVideoWithBlueColor(); |
340 | } |
341 | SetAudioMuteForTv ( CC_AUDIO_MUTE ); |
342 | |
343 | TvEvent::SignalInfoEvent ev; |
344 | ev.mStatus = TVIN_SIG_STATUS_NOSIG; |
345 | ev.mTrans_fmt = TVIN_TFMT_2D; |
346 | ev.mFmt = TVIN_SIG_FMT_NULL; |
347 | ev.mReserved = 0; |
348 | sendTvEvent ( ev ); |
349 | break; |
350 | } |
351 | |
352 | case CAv::AVEvent::EVENT_AV_RESUEM: { |
353 | //if (mAv.WaittingVideoPlaying() == 0) { |
354 | SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), |
355 | CTvin::Tvin_SourceInputToSourceInputType(m_source_input), |
356 | mAv.getVideoResolutionToFmt()); |
357 | usleep(50 * 1000); |
358 | mAv.EnableVideoNow(); |
359 | SetAudioMuteForTv ( CC_AUDIO_UNMUTE ); |
360 | //} |
361 | TvEvent::AVPlaybackEvent AvPlayBackEvt; |
362 | AvPlayBackEvt.mMsgType = TvEvent::AVPlaybackEvent::EVENT_AV_PLAYBACK_RESUME; |
363 | AvPlayBackEvt.mProgramId = ( int ) ev.param; |
364 | sendTvEvent(AvPlayBackEvt ); |
365 | break; |
366 | } |
367 | |
368 | case CAv::AVEvent::EVENT_AV_SCAMBLED: { |
369 | config_value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); |
370 | if ( strcmp ( config_value, "black" ) == 0 ) { |
371 | mAv.DisableVideoWithBlackColor(); |
372 | } else { |
373 | mAv.DisableVideoWithBlueColor(); |
374 | } |
375 | TvEvent::AVPlaybackEvent AvPlayBackEvt; |
376 | AvPlayBackEvt.mMsgType = TvEvent::AVPlaybackEvent::EVENT_AV_SCAMBLED; |
377 | AvPlayBackEvt.mProgramId = ( int ) ev.param; |
378 | sendTvEvent(AvPlayBackEvt ); |
379 | break; |
380 | } |
381 | |
382 | case CAv::AVEvent::EVENT_AV_UNSUPPORT: { |
383 | LOGD("To AVS or AVS+ format");//just avs format, not unsupport, and avs avs+ |
384 | break; |
385 | } |
386 | |
387 | default: |
388 | break; |
389 | } |
390 | } |
391 | |
392 | CTv::CTvMsgQueue::CTvMsgQueue(CTv *tv) |
393 | { |
394 | mpTv = tv; |
395 | } |
396 | |
397 | CTv::CTvMsgQueue::~CTvMsgQueue() |
398 | { |
399 | } |
400 | |
401 | void CTv::CTvMsgQueue::handleMessage ( CMessage &msg ) |
402 | { |
403 | LOGD ("%s, CTv::CTvMsgQueue::handleMessage type = %d", __FUNCTION__, msg.mType); |
404 | |
405 | switch ( msg.mType ) { |
406 | case TV_MSG_COMMON: |
407 | break; |
408 | |
409 | case TV_MSG_STOP_ANALYZE_TS: |
410 | //mpTv->Tv_Stop_Analyze_Ts(); |
411 | break; |
412 | |
413 | case TV_MSG_START_ANALYZE_TS: |
414 | //mpTv->Tv_Start_Analyze_Ts ( pTv->mCurAnalyzeTsChannelID ); |
415 | break; |
416 | |
417 | case TV_MSG_CHECK_FE_DELAY: { |
418 | mpTv->mFrontDev.checkStatusOnce(); |
419 | break; |
420 | } |
421 | |
422 | case TV_MSG_AV_EVENT: { |
423 | mpTv->onEvent(*((CAv::AVEvent *)(msg.mpPara))); |
424 | break; |
425 | } |
426 | |
427 | case TV_MSG_FE_EVENT: { |
428 | mpTv->onEvent(*((CFrontEnd::FEEvent *)(msg.mpPara))); |
429 | break; |
430 | } |
431 | |
432 | case TV_MSG_SCAN_EVENT: { |
433 | mpTv->onEvent(*((CTvScanner::ScannerEvent *)(msg.mpPara))); |
434 | break; |
435 | } |
436 | |
437 | case TV_MSG_EPG_EVENT: { |
438 | mpTv->onEvent(*((CTvEpg::EpgEvent *)(msg.mpPara))); |
439 | break; |
440 | } |
441 | |
442 | case TV_MSG_HDMI_SR_CHANGED: { |
443 | int sr = ((int *)(msg.mpPara))[0]; |
444 | mpTv->onHdmiSrChanged(sr, (((int *)(msg.mpPara))[1] == 0) ? true : false); |
445 | break; |
446 | } |
447 | |
448 | case TV_MSG_ENABLE_VIDEO_LATER: { |
449 | int fc = msg.mpPara[0]; |
450 | mpTv->onEnableVideoLater(fc); |
451 | break; |
452 | } |
453 | |
454 | default: |
455 | break; |
456 | } |
457 | } |
458 | |
459 | void CTv::onHdmiSrChanged(int sr, bool bInit) |
460 | { |
461 | if (bInit) { |
462 | LOGD ( "%s, Init HDMI audio, sampling rate:%d", __FUNCTION__, sr ); |
463 | sr = HanldeAudioInputSr(sr); |
464 | InitTvAudio (sr, CC_IN_USE_SPDIF_DEVICE); |
465 | } else { |
466 | LOGD ( "%s, Reset HDMI sampling rate to %d", __FUNCTION__, sr ); |
467 | AudioChangeSampleRate ( sr ); |
468 | } |
469 | } |
470 | |
471 | void CTv::onHMDIAudioStatusChanged(int status) |
472 | { |
473 | if (status == 0) {//change to no audio data |
474 | SetAudioMuteForTv ( CC_AUDIO_MUTE ); |
475 | } else if (status == 1) {//change to audio data come |
476 | Tv_SetAudioInSource(m_source_input); |
477 | usleep(200 * 1000); |
478 | SetAudioMuteForTv ( CC_AUDIO_UNMUTE ); |
479 | } |
480 | } |
481 | |
482 | void CTv::CTvMsgQueue::onEvent ( const CTvScanner::ScannerEvent &ev ) |
483 | { |
484 | CMessage msg; |
485 | msg.mDelayMs = 0; |
486 | msg.mType = CTvMsgQueue::TV_MSG_SCAN_EVENT; |
487 | memcpy(msg.mpPara, &ev, sizeof(ev)); |
488 | this->sendMsg ( msg ); |
489 | } |
490 | |
491 | void CTv::CTvMsgQueue::onEvent ( const CFrontEnd::FEEvent &ev ) |
492 | { |
493 | CMessage msg; |
494 | msg.mDelayMs = 0; |
495 | msg.mType = CTvMsgQueue::TV_MSG_FE_EVENT; |
496 | memcpy(msg.mpPara, &ev, sizeof(ev)); |
497 | this->sendMsg ( msg ); |
498 | } |
499 | |
500 | void CTv::CTvMsgQueue::onEvent ( const CTvEpg::EpgEvent &ev ) |
501 | { |
502 | CMessage msg; |
503 | msg.mDelayMs = 0; |
504 | msg.mType = CTvMsgQueue::TV_MSG_EPG_EVENT; |
505 | memcpy(msg.mpPara, &ev, sizeof(ev)); |
506 | this->sendMsg ( msg ); |
507 | } |
508 | |
509 | void CTv::CTvMsgQueue::onEvent(const CAv::AVEvent &ev) |
510 | { |
511 | CMessage msg; |
512 | msg.mDelayMs = 0; |
513 | msg.mType = CTvMsgQueue::TV_MSG_AV_EVENT; |
514 | memcpy(msg.mpPara, &ev, sizeof(ev)); |
515 | this->sendMsg ( msg ); |
516 | } |
517 | |
518 | int CTv::setTvObserver ( TvIObserver *ob ) |
519 | { |
520 | mpObserver = ob; |
521 | return 0; |
522 | } |
523 | |
524 | void CTv::sendTvEvent ( const CTvEv &ev ) |
525 | { |
526 | //AutoMutex lock(mLock); |
527 | /* send sigstate to AutoBackLight */ |
528 | if (ev.getEvType() == CTvEv::TV_EVENT_SIGLE_DETECT) { |
529 | TvEvent::SignalInfoEvent *pEv = (TvEvent::SignalInfoEvent *)(&ev); |
530 | if (pEv->mStatus == TVIN_SIG_STATUS_STABLE) { |
531 | mAutoBackLight.updateSigState(mAutoBackLight.SIG_STATE_STABLE); |
532 | } else { |
533 | mAutoBackLight.updateSigState(mAutoBackLight.SIG_STATE_NOSIG); |
534 | } |
535 | } |
536 | |
537 | LOGD ( "%s, tvaction=%x", __FUNCTION__, mTvAction); |
538 | if ((mTvAction & TV_ACTION_SCANNING) && (ev.getEvType() == CTvEv::TV_EVENT_SIGLE_DETECT)) { |
539 | LOGD("%s, when scanning, not send sig detect event", __FUNCTION__); |
540 | return; |
541 | } |
542 | if ( mpObserver != NULL ) { |
543 | mpObserver->onTvEvent ( ev ); |
544 | } |
545 | } |
546 | |
547 | int CTv::ClearAnalogFrontEnd() |
548 | { |
549 | return mFrontDev.ClearAnalogFrontEnd (); |
550 | } |
551 | |
552 | int CTv::dtvAutoScan() |
553 | { |
554 | AutoMutex lock ( mLock ); |
555 | mTvAction |= TV_ACTION_SCANNING; |
556 | //mTvEpg.leaveChannel(); |
557 | mAv.StopTS (); |
558 | mAv.DisableVideoWithBlueColor(); |
559 | CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_DTV ); |
560 | CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_RADIO ); |
561 | CTvEvent::CleanAllEvent(); |
562 | mTvScanner.setObserver ( &mTvMsgQueue ); |
563 | mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL; |
564 | mFrontDev.Open(FE_DTMB); |
565 | mTvScanner.autoDtmbScan();//dtmb |
566 | return 0; |
567 | } |
568 | |
569 | int CTv::dtvCleanProgramByFreq ( int freq ) |
570 | { |
571 | int iOutRet = 0; |
572 | CTvChannel channel; |
573 | iOutRet = CTvChannel::SelectByFreq ( freq, channel ); |
574 | if ( -1 == iOutRet ) { |
575 | LOGD ( "%s, Warnning: Current Freq not have program info in the ts_table\n", __FUNCTION__ ); |
576 | } |
577 | |
578 | iOutRet == CTvProgram::deleteChannelsProgram ( channel ); |
579 | return iOutRet; |
580 | } |
581 | |
582 | int CTv::dtvManualScan (int beginFreq, int endFreq, int modulation) |
583 | { |
584 | AutoMutex lock ( mLock ); |
585 | mTvAction |= TV_ACTION_SCANNING; |
586 | //mTvEpg.leaveChannel(); |
587 | mAv.StopTS (); |
588 | mAv.DisableVideoWithBlueColor(); |
589 | CTvChannel::DeleteBetweenFreq(beginFreq, endFreq); |
590 | mTvScanner.setObserver ( &mTvMsgQueue ); |
591 | mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL; |
592 | mFrontDev.Open(FE_DTMB); |
593 | int iOutRet = mTvScanner.manualDtmbScan (beginFreq, endFreq, modulation); //dtmb |
594 | return iOutRet; |
595 | } |
596 | |
597 | int CTv::dtvAutoScanAtscLock(int attenna, int videoStd, int audioStd) |
598 | { |
599 | //for warning |
600 | attenna = attenna; |
601 | videoStd = videoStd; |
602 | audioStd = audioStd; |
603 | //showboz |
604 | /* int minScanFreq, maxScanFreq, vStd, aStd; |
605 | vStd = CC_ATV_VIDEO_STD_PAL; |
606 | aStd = CC_ATV_AUDIO_STD_DK; |
607 | v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor(vStd, aStd); |
608 | |
609 | AutoMutex lock ( mLock ); |
610 | mTvAction |= TV_ACTION_SCANNING; |
611 | mTvEpg.leaveChannel(); |
612 | mAv.StopTS (); |
613 | mAv.DisableVideoWithBlueColor(); |
614 | CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_DTV ); |
615 | CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_RADIO ); |
616 | CTvEvent::CleanAllEvent(); |
617 | mTvScanner.setObserver ( &mTvMsgQueue ); |
618 | mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL; |
619 | mFrontDev.Open(FE_ATSC); |
620 | mTvScanner.autoAtscScan(CTvScanner::AM_ATSC_ATTENNA_TYPE_AIR, stdAndColor);//dtmb*/ |
621 | return 0; |
622 | } |
623 | |
624 | //searchType 0:not 256 1:is 256 Program |
625 | int CTv::atvAutoScan(int videoStd, int audioStd, int searchType) |
626 | { |
627 | int minScanFreq, maxScanFreq, vStd, aStd; |
628 | AutoMutex lock ( mLock ); |
629 | mAv.DisableVideoWithBlueColor(); |
630 | mTvAction |= TV_ACTION_SCANNING; |
631 | stopPlaying(); |
632 | mTvScanner.setObserver ( &mTvMsgQueue ); |
633 | SetAudioMuteForTv ( CC_AUDIO_MUTE ); |
634 | getATVMinMaxFreq (&minScanFreq, &maxScanFreq ); |
635 | if ( minScanFreq == 0 || maxScanFreq == 0 || minScanFreq > maxScanFreq ) { |
636 | LOGE ( "%s, auto scan freq set is error min=%d, max=%d", __FUNCTION__, minScanFreq, maxScanFreq ); |
637 | return -1; |
638 | } |
639 | mSigDetectThread.setVdinNoSigCheckKeepTimes(1000, false); |
640 | mSigDetectThread.requestAndWaitPauseDetect(); |
641 | mSigDetectThread.setObserver(&mTvScannerDetectObserver); |
642 | mTvin.Tvin_StopDecoder(); |
643 | //if set std null AUTO, use default PAL/DK |
644 | //if(videoStd == CC_ATV_VIDEO_STD_AUTO) { |
645 | // vStd = CC_ATV_VIDEO_STD_PAL; |
646 | // aStd = CC_ATV_AUDIO_STD_DK; |
647 | //} else { |
648 | vStd = CC_ATV_VIDEO_STD_PAL; |
649 | aStd = CC_ATV_AUDIO_STD_DK; |
650 | //} |
651 | tvin_port_t source_port = mTvin.Tvin_GetSourcePortBySourceInput(SOURCE_TV); |
652 | mTvin.VDIN_OpenPort ( source_port ); |
653 | v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor(vStd, aStd); |
654 | |
655 | int fmt = CFrontEnd::stdEnumToCvbsFmt (vStd, aStd); |
656 | mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) TVIN_SIG_FMT_NULL ); |
657 | |
658 | if (searchType == 0) { |
659 | CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_ATV ); |
660 | } else if (searchType == 1) { //type for skyworth, and insert 256 prog, and just update ts table |
661 | } |
662 | minScanFreq = mFrontDev.formatATVFreq ( minScanFreq ); |
663 | maxScanFreq = mFrontDev.formatATVFreq ( maxScanFreq ); |
664 | LOGD("%s, atv auto scan vstd=%d, astd=%d stdandcolor=%lld", __FUNCTION__, vStd, aStd, stdAndColor); |
665 | mFrontDev.Open(FE_ANALOG); |
666 | mSigDetectThread.initSigState(); |
667 | mSigDetectThread.resumeDetect(); |
668 | mTvScanner.autoAtvScan ( minScanFreq, maxScanFreq, stdAndColor, searchType); |
669 | return 0; |
670 | } |
671 | |
672 | int CTv::clearAllProgram(int arg0) |
673 | { |
674 | CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_ATV ); |
675 | CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_TV ); |
676 | CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_DTV ); |
677 | CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_RADIO); |
678 | return 0; |
679 | } |
680 | |
681 | int CTv::atvMunualScan ( int startFreq, int endFreq, int videoStd, int audioStd, |
682 | int store_Type , int channel_num ) |
683 | { |
684 | int minScanFreq, maxScanFreq, vStd, aStd; |
685 | |
686 | minScanFreq = mFrontDev.formatATVFreq ( startFreq ); |
687 | maxScanFreq = mFrontDev.formatATVFreq ( endFreq ); |
688 | if ( minScanFreq == 0 || maxScanFreq == 0 ) { |
689 | LOGE ( "%s, munual scan freq set is error min=%d, max=%d", __FUNCTION__, minScanFreq, maxScanFreq ); |
690 | return -1; |
691 | } |
692 | |
693 | //if set std null AUTO, use default PAL/DK |
694 | //if(videoStd == CC_ATV_VIDEO_STD_AUTO) { |
695 | // vStd = CC_ATV_VIDEO_STD_PAL; |
696 | // aStd = CC_ATV_AUDIO_STD_DK; |
697 | // } else { |
698 | vStd = videoStd; |
699 | aStd = audioStd; |
700 | // } |
701 | |
702 | AutoMutex lock ( mLock ); |
703 | mAv.DisableVideoWithBlueColor(); |
704 | mTvAction |= TV_ACTION_SCANNING; |
705 | mTvScanner.setObserver ( &mTvMsgQueue ); |
706 | |
707 | SetAudioMuteForTv ( CC_AUDIO_MUTE ); |
708 | v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor(vStd, aStd); |
709 | |
710 | tvin_port_t source_port = mTvin.Tvin_GetSourcePortBySourceInput(SOURCE_TV); |
711 | mTvin.VDIN_OpenPort ( source_port ); |
712 | |
713 | int fmt = CFrontEnd::stdEnumToCvbsFmt (vStd, aStd); |
714 | mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) TVIN_SIG_FMT_NULL ); |
715 | LOGD("%s, atv manual scan vstd=%d, astd=%d stdandcolor=%lld", __FUNCTION__, vStd, aStd, stdAndColor); |
716 | mFrontDev.Open(FE_ANALOG); |
717 | return mTvScanner.ATVManualScan ( minScanFreq, maxScanFreq, stdAndColor, store_Type, channel_num); |
718 | } |
719 | |
720 | int CTv::getVideoFormatInfo ( int *pWidth, int *pHeight, int *pFPS, int *pInterlace ) |
721 | { |
722 | int iOutRet = -1; |
723 | AM_AV_VideoStatus_t video_status; |
724 | |
725 | do { |
726 | if ( NULL == pWidth || NULL == pHeight || NULL == pFPS || NULL == pInterlace ) { |
727 | break; |
728 | } |
729 | |
730 | iOutRet = mAv.GetVideoStatus (&video_status ); |
731 | |
732 | if ( AM_SUCCESS != iOutRet ) { |
733 | LOGD ( "%s, ERROR: Cann't Get video format info\n", __FUNCTION__); |
734 | break; |
735 | } |
736 | |
737 | *pWidth = video_status.src_w; |
738 | *pHeight = video_status.src_h; |
739 | *pFPS = video_status.fps; |
740 | *pInterlace = video_status.interlaced; |
741 | //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); |
742 | } while ( false ); |
743 | |
744 | return iOutRet; |
745 | } |
746 | |
747 | int CTv::stopScanLock() |
748 | { |
749 | AutoMutex lock ( mLock ); |
750 | return stopScan(); |
751 | } |
752 | |
753 | int CTv::stopScan() |
754 | { |
755 | const char *config_value = NULL; |
756 | if (!(mTvAction & TV_ACTION_SCANNING)) { |
757 | LOGD("%s, tv not scanning ,return\n", __FUNCTION__); |
758 | return 0; |
759 | } |
760 | |
761 | LOGD("%s, tv scanning , stop it\n", __FUNCTION__); |
762 | config_value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); |
763 | if ( strcmp ( config_value, "black" ) == 0 ) { |
764 | mAv.DisableVideoWithBlackColor(); |
765 | } else { |
766 | mAv.DisableVideoWithBlueColor(); |
767 | } |
768 | mSigDetectThread.requestAndWaitPauseDetect(); |
769 | mSigDetectThread.setObserver(this); |
770 | //mTvEpg.leaveChannel(); |
771 | mTvScanner.stopScan(); |
772 | mFrontDev.Close(); |
773 | mTvAction &= ~TV_ACTION_SCANNING; |
774 | return 0; |
775 | } |
776 | |
777 | int CTv::playProgramLock ( int progId ) |
778 | { |
779 | /*AutoMutex lock ( mLock ); |
780 | CTvProgram prog; |
781 | int ret = CTvProgram::selectByID ( progId, prog ); |
782 | |
783 | if ( ret != 0 ) { |
784 | return -1; |
785 | } |
786 | int type = prog.getProgType(); |
787 | LOGD ( "%s, blackout = %dprog type = %d id = %d name = %s\n", __FUNCTION__, m_blackout_enable, type, progId, prog.getName().string() ); |
788 | if (m_blackout_enable == 1) { |
789 | mAv.EnableVideoBlackout(); |
790 | }else if (m_blackout_enable == 0){ |
791 | mAv.DisableVideoBlackout(); |
792 | } |
793 | |
794 | mTvAction |= TV_ACTION_PLAYING; |
795 | m_cur_playing_prog_id = progId; |
796 | mFrontDev.Open(FE_ANALOG); |
797 | if ( m_source_input == SOURCE_TV && type == CTvProgram::TYPE_ATV ) { |
798 | playAtvProgram ( progId ); |
799 | } else if ( m_source_input == SOURCE_DTV && ( type == CTvProgram::TYPE_DTV || type == CTvProgram::TYPE_RADIO ) ) { |
800 | playDtmbProgram ( progId ); |
801 | } else { |
802 | LOGD ( "%s, source(%d) != type(%d),not play\n", __FUNCTION__, m_source_input, type ); |
803 | } |
804 | //just for ui,left/right/stereo |
805 | int audio_ch = prog.getAudioChannel(); |
806 | AM_AOUT_OutputMode_t channel = AM_AOUT_OUTPUT_STEREO; |
807 | if (audio_ch == 1) { |
808 | channel = AM_AOUT_OUTPUT_STEREO; |
809 | } else if (audio_ch == 2) { |
810 | channel = AM_AOUT_OUTPUT_DUAL_LEFT; |
811 | } else if (audio_ch == 3) { |
812 | channel = AM_AOUT_OUTPUT_DUAL_RIGHT; |
813 | } |
814 | setAudioChannel((int)channel);*/ |
815 | return 0; |
816 | } |
817 | |
818 | int CTv::playDvbcProgram ( int progId ) |
819 | { |
820 | LOGD ( "%s, progId = %d\n", __FUNCTION__, progId ); |
821 | |
822 | CTvProgram prog; |
823 | int ret = CTvProgram::selectByID ( progId, prog ); |
824 | if ( ret != 0 ) { |
825 | return -1; |
826 | } |
827 | |
828 | LOGD ( "%s, prog name = %s\n", __FUNCTION__, prog.getName().string() ); |
829 | CTvChannel channel; |
830 | prog.getChannel ( channel ); |
831 | |
832 | mFrontDev.setPara ( channel.getMode(), channel.getFrequency(), channel.getSymbolRate(), channel.getModulation() ); |
833 | |
834 | int vpid = 0x1fff, apid = 0x1fff, vfmt = -1, afmt = -1; |
835 | |
836 | CTvProgram::Video *pV = prog.getVideo(); |
837 | if ( pV != NULL ) { |
838 | vpid = pV->getPID(); |
839 | vfmt = pV->getFormat(); |
840 | } |
841 | |
842 | int aindex = prog.getCurrentAudio ( String8 ( "eng" ) ); |
843 | if ( aindex >= 0 ) { |
844 | CTvProgram::Audio *pA = prog.getAudio ( aindex ); |
845 | if ( pA != NULL ) { |
846 | apid = pA->getPID(); |
847 | afmt = pA->getFormat(); |
848 | } |
849 | } |
850 | mTvEpg.leaveProgram(); |
851 | mTvEpg.leaveChannel(); |
852 | startPlayTv ( SOURCE_DTV, vpid, apid, vfmt, afmt ); |
853 | |
854 | mTvEpg.enterChannel ( channel.getID() ); |
855 | mTvEpg.enterProgram ( prog.getID() ); |
856 | return 0; |
857 | } |
858 | |
859 | int CTv::getAudioTrackNum ( int progId ) |
860 | { |
861 | int iRet, iOutCnt = 0; |
862 | CTvProgram prog; |
863 | |
864 | do { |
865 | if ( 0 > progId ) { |
866 | break; |
867 | } |
868 | |
869 | iRet = CTvProgram::selectByID ( progId, prog ); |
870 | if ( 0 != iRet ) { |
871 | break; |
872 | } |
873 | |
874 | iOutCnt = prog.getAudioTrackSize(); |
875 | } while ( false ); |
876 | |
877 | return iOutCnt; |
878 | } |
879 | |
880 | int CTv::getAudioInfoByIndex ( int progId, int idx, int *pAFmt, String8 &lang ) |
881 | { |
882 | int iRet, iOutRet = -1; |
883 | CTvProgram prog; |
884 | CTvProgram::Audio *pA = NULL; |
885 | |
886 | do { |
887 | if ( NULL == pAFmt || idx < 0 ) { |
888 | break; |
889 | } |
890 | |
891 | iRet = CTvProgram::selectByID ( progId, prog ); |
892 | if ( 0 != iRet ) { |
893 | break; |
894 | } |
895 | |
896 | if ( idx >= prog.getAudioTrackSize() ) { |
897 | break; |
898 | } |
899 | |
900 | pA = prog.getAudio ( idx ); |
901 | if ( NULL == pA ) { |
902 | break; |
903 | } |
904 | |
905 | *pAFmt = pA->getFormat(); |
906 | lang = pA->getLang(); |
907 | } while ( false ); |
908 | |
909 | return iOutRet; |
910 | } |
911 | |
912 | int CTv::switchAudioTrack ( int aPid, int aFmt, int aParam ) |
913 | { |
914 | int iOutRet = 0; |
915 | |
916 | do { |
917 | if ( aPid < 0 || aFmt < 0 ) { |
918 | break; |
919 | } |
920 | |
921 | iOutRet = mAv.SwitchTSAudio (( uint16_t ) aPid, ( AM_AV_AFormat_t ) aFmt ); |
922 | LOGD ( "%s, iOutRet = %d AM_AV_SwitchTSAudio\n", __FUNCTION__, iOutRet ); |
923 | } while ( false ); |
924 | |
925 | return iOutRet; |
926 | } |
927 | |
928 | int CTv::switchAudioTrack ( int progId, int idx ) |
929 | { |
930 | int iOutRet = 0; |
931 | CTvProgram prog; |
932 | CTvProgram::Audio *pAudio = NULL; |
933 | int aPid = -1; |
934 | int aFmt = -1; |
935 | |
936 | do { |
937 | if ( idx < 0 ) { |
938 | break; |
939 | } |
940 | |
941 | iOutRet = CTvProgram::selectByID ( progId, prog ); |
942 | if ( 0 != iOutRet ) { |
943 | break; |
944 | } |
945 | if (prog.getAudioTrackSize() <= 1) { |
946 | LOGD("%s, just one audio track, not to switch", __FUNCTION__); |
947 | break; |
948 | } |
949 | if ( idx >= prog.getAudioTrackSize() ) { |
950 | break; |
951 | } |
952 | |
953 | pAudio = prog.getAudio ( idx ); |
954 | if ( NULL == pAudio ) { |
955 | break; |
956 | } |
957 | |
958 | aPid = pAudio->getPID(); |
959 | aFmt = pAudio->getFormat(); |
960 | if ( aPid < 0 || aFmt < 0 ) { |
961 | break; |
962 | } |
963 | |
964 | iOutRet = mAv.SwitchTSAudio (( uint16_t ) aPid, ( AM_AV_AFormat_t ) aFmt ); |
965 | LOGD ( "%s, iOutRet = %d AM_AV_SwitchTSAudio\n", __FUNCTION__, iOutRet ); |
966 | } while ( false ); |
967 | |
968 | return iOutRet; |
969 | } |
970 | |
971 | int CTv::ResetAudioDecoderForPCMOutput() |
972 | { |
973 | int iOutRet = 0; |
974 | |
975 | iOutRet = mAv.ResetAudioDecoder (); |
976 | LOGD ( "%s, iOutRet = %d AM_AV_ResetAudioDecoder\n", __FUNCTION__, iOutRet ); |
977 | return iOutRet; |
978 | } |
979 | |
980 | int CTv::playDtvProgram ( int mode, int freq, int para1, int para2, |
981 | int vpid, int vfmt, int apid, int afmt, int pcr, int audioCompetation) |
982 | { |
983 | AutoMutex lock ( mLock ); |
984 | mTvAction |= TV_ACTION_PLAYING; |
985 | if ( m_blackout_enable == 1 ) { |
986 | mAv.EnableVideoBlackout(); |
987 | } else if ( m_blackout_enable == 0 ) { |
988 | mAv.DisableVideoBlackout(); |
989 | } |
990 | mFrontDev.Open(FE_ANALOG); |
991 | mFrontDev.setPara ( mode, freq, para1, para2); |
992 | mTvAction |= TV_ACTION_PLAYING; |
993 | startPlayTv ( SOURCE_DTV, vpid, apid, vfmt, afmt ); |
994 | // |
995 | CMessage msg; |
996 | msg.mDelayMs = 2000; |
997 | msg.mType = CTvMsgQueue::TV_MSG_CHECK_FE_DELAY; |
998 | mTvMsgQueue.sendMsg ( msg ); |
999 | SetCurProgramAudioVolumeCompensationVal ( audioCompetation ); |
1000 | return 0; |
1001 | } |
1002 | |
1003 | int CTv::playDtmbProgram ( int progId ) |
1004 | { |
1005 | CTvProgram prog; |
1006 | CTvChannel channel; |
1007 | int vpid = 0x1fff, apid = 0x1fff, vfmt = -1, afmt = -1; |
1008 | int aindex; |
1009 | CTvProgram::Audio *pA; |
1010 | CTvProgram::Video *pV; |
1011 | int ret = CTvProgram::selectByID ( progId, prog ); |
1012 | |
1013 | SetAudioMuteForTv ( CC_AUDIO_MUTE ); |
1014 | saveDTVProgramID ( progId ); |
1015 | prog.getChannel ( channel ); |
1016 | //音量补偿 |
1017 | int chanVolCompValue = 0; |
1018 | chanVolCompValue = GetAudioVolumeCompensationVal(progId); |
1019 | SetCurProgramAudioVolumeCompensationVal ( chanVolCompValue ); |
1020 | |
1021 | mFrontDev.setPara ( channel.getMode(), channel.getFrequency(), channel.getBandwidth(), 0 ); |
1022 | |
1023 | pV = prog.getVideo(); |
1024 | if ( pV != NULL ) { |
1025 | vpid = pV->getPID(); |
1026 | vfmt = pV->getFormat(); |
1027 | } |
1028 | |
1029 | aindex = prog.getCurrAudioTrackIndex(); |
1030 | if ( -1 == aindex ) { //db is default |
1031 | aindex = prog.getCurrentAudio ( String8 ( "eng" ) ); |
1032 | if ( aindex >= 0 ) { |
1033 | prog.setCurrAudioTrackIndex ( progId, aindex ); |
1034 | } |
1035 | } |
1036 | |
1037 | if ( aindex >= 0 ) { |
1038 | pA = prog.getAudio ( aindex ); |
1039 | if ( pA != NULL ) { |
1040 | apid = pA->getPID(); |
1041 | afmt = pA->getFormat(); |
1042 | } |
1043 | } |
1044 | |
1045 | mTvEpg.leaveProgram(); |
1046 | mTvEpg.leaveChannel(); |
1047 | startPlayTv ( SOURCE_DTV, vpid, apid, vfmt, afmt ); |
1048 | mTvEpg.enterChannel ( channel.getID() ); |
1049 | mTvEpg.enterProgram ( prog.getID() ); |
1050 | return 0; |
1051 | } |
1052 | |
1053 | int CTv::playAtvProgram (int freq, int videoStd, int audioStd, int fineTune, int audioCompetation) |
1054 | { |
1055 | mTvAction |= TV_ACTION_PLAYING; |
1056 | if ( m_blackout_enable == 1 ) { |
1057 | mAv.EnableVideoBlackout(); |
1058 | } else if ( m_blackout_enable == 0 ) { |
1059 | mAv.DisableVideoBlackout(); |
1060 | } |
1061 | SetAudioMuteForTv ( CC_AUDIO_MUTE ); |
1062 | //image selecting channel |
1063 | mSigDetectThread.requestAndWaitPauseDetect(); |
1064 | mTvin.Tvin_StopDecoder(); |
1065 | mFrontDev.Open(FE_ANALOG); |
1066 | //set CVBS |
1067 | int fmt = CFrontEnd::stdEnumToCvbsFmt (videoStd, audioStd); |
1068 | mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt ); |
1069 | |
1070 | v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor (videoStd, audioStd); |
1071 | //set TUNER |
1072 | mFrontDev.setPara (FE_ANALOG, freq, stdAndColor, 1); |
1073 | |
1074 | mSigDetectThread.setObserver ( this ); |
1075 | mSigDetectThread.initSigState(); |
1076 | mSigDetectThread.resumeDetect(1000); |
1077 | |
1078 | SetCurProgramAudioVolumeCompensationVal ( audioCompetation ); |
1079 | return 0; |
1080 | } |
1081 | |
1082 | int CTv::resetFrontEndPara ( frontend_para_set_t feParms ) |
1083 | { |
1084 | if ( feParms.mode == FE_ANALOG ) { |
1085 | int progID = -1; |
1086 | int tmpFreq = feParms.freq; |
1087 | int tmpfineFreq = feParms.para2; |
1088 | int mode = feParms.mode; |
1089 | |
1090 | //get tunerStd from videoStd and audioStd |
1091 | v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor (feParms.videoStd, feParms.audioStd); |
1092 | |
1093 | LOGD("%s, resetFrontEndPara- vstd=%d astd=%d stdandcolor=%lld", __FUNCTION__, feParms.videoStd, feParms.audioStd, stdAndColor); |
1094 | |
1095 | //set frontend parameters to tuner dev |
1096 | mSigDetectThread.requestAndWaitPauseDetect(); |
1097 | mTvin.Tvin_StopDecoder(); |
1098 | |
1099 | //set CVBS |
1100 | int fmt = CFrontEnd::stdEnumToCvbsFmt (feParms.videoStd, feParms.audioStd ); |
1101 | mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt ); |
1102 | |
1103 | //set TUNER |
1104 | usleep(400 * 1000); |
1105 | mFrontDev.setPara ( FE_ANALOG, tmpFreq, stdAndColor, 1 ); |
1106 | usleep(400 * 1000); |
1107 | if ( tmpfineFreq != 0 ) { |
1108 | mFrontDev.fineTune ( tmpfineFreq / 1000 ); |
1109 | } |
1110 | |
1111 | mSigDetectThread.initSigState(); |
1112 | mSigDetectThread.resumeDetect(); |
1113 | } else if ( feParms.mode == FE_DTMB ) { |
1114 | mFrontDev.setPara ( FE_DTMB, feParms.freq, feParms.para1, feParms.para2 ); |
1115 | } |
1116 | |
1117 | return 0; |
1118 | } |
1119 | |
1120 | int CTv::resetDmxAndAvSource() |
1121 | { |
1122 | AM_DMX_Source_t curdmxSource; |
1123 | mFrontDev.GetTSSource ( &curdmxSource ); |
1124 | LOGD ( "%s, AM_FEND_GetTSSource %d", __FUNCTION__, curdmxSource ); |
1125 | mTvDmx.Close(); |
1126 | AM_DMX_OpenPara_t para; |
1127 | memset ( ¶, 0, sizeof ( para ) ); |
1128 | mTvDmx.Open (para); |
1129 | mTvDmx.SetSource(curdmxSource ); |
1130 | AM_AV_TSSource_t ts_source = ( AM_AV_TSSource_t ) curdmxSource; |
1131 | mAv.SetTSSource (ts_source ); |
1132 | return 0; |
1133 | } |
1134 | |
1135 | int CTv::SetCurProgramAudioVolumeCompensationVal ( int tmpVal ) |
1136 | { |
1137 | SetAudioVolumeCompensationVal ( tmpVal ); |
1138 | SetAudioMasterVolume (GetAudioMasterVolume() ); |
1139 | |
1140 | LOGD ( "%s, VolumeCompensationVal = %d, id = %d\n", __FUNCTION__, tmpVal, m_cur_playing_prog_id ); |
1141 | CTvProgram prog; |
1142 | if ( CTvProgram::selectByID ( m_cur_playing_prog_id, prog ) != 0 ) { |
1143 | LOGE ( "%s, atv progID is not matching the db's ret = 0\n", __FUNCTION__ ); |
1144 | return -1; |
1145 | } |
1146 | |
1147 | if (prog.updateVolComp ( m_cur_playing_prog_id, tmpVal ) != 0 ) { |
1148 | LOGE ( "%s, atv progID is not matching the db's\n", __FUNCTION__); |
1149 | return -1; |
1150 | } |
1151 | return 0; |
1152 | } |
1153 | |
1154 | int CTv::GetAudioVolumeCompensationVal(int progxxId) |
1155 | { |
1156 | int tmpVolValue = 0; |
1157 | CTvProgram prog; |
1158 | if ( CTvProgram::selectByID ( m_cur_playing_prog_id, prog ) != 0 ) { |
1159 | LOGE ( "%s, atv progID is not matching the db's ret = 0\n", __FUNCTION__ ); |
1160 | return tmpVolValue; |
1161 | } |
1162 | tmpVolValue = prog.getChanVolume (); |
1163 | LOGD ( "%s,progid = %d CompensationVal = %d\n", __FUNCTION__, m_cur_playing_prog_id, tmpVolValue ); |
1164 | if (tmpVolValue > 20 || tmpVolValue < -20) tmpVolValue = 0; |
1165 | return tmpVolValue; |
1166 | } |
1167 | |
1168 | int CTv::startPlayTv ( int source, int vid, int aid, int vfat, int afat ) |
1169 | { |
1170 | if ( source == SOURCE_DTV ) { |
1171 | AM_FileEcho ( DEVICE_CLASS_TSYNC_AV_THRESHOLD_MIN, AV_THRESHOLD_MIN_MS ); |
1172 | LOGD ( "%s, startPlayTv", __FUNCTION__); |
1173 | mAv.StartTS (vid, aid, ( AM_AV_VFormat_t ) vfat, ( AM_AV_AFormat_t ) afat ); |
1174 | } |
1175 | return 0; |
1176 | } |
1177 | |
1178 | int CTv::stopPlayingLock() |
1179 | { |
1180 | AutoMutex lock ( mLock ); |
1181 | if (getSubSwitchStatus() == 1) |
1182 | stopSubtitle(); |
1183 | return stopPlaying(); |
1184 | } |
1185 | |
1186 | int CTv::stopPlaying() |
1187 | { |
1188 | const char *config_value = NULL; |
1189 | if (!(mTvAction & TV_ACTION_PLAYING)) { |
1190 | LOGD("%s, stopplay cur action = %x not playing , return", __FUNCTION__, mTvAction); |
1191 | return 0; |
1192 | } |
1193 | mSigDetectThread.requestAndWaitPauseDetect(); |
1194 | mAv.EnableVideoBlackout(); |
1195 | if (m_source_input == SOURCE_TV) { |
1196 | //first mute |
1197 | SetAudioMuteForTv(CC_AUDIO_MUTE); |
1198 | ClearAnalogFrontEnd(); |
1199 | } else if (m_source_input == SOURCE_DTV) { |
1200 | //mFrontDev.setPara(FE_DTMB, 51000000, 0, 0); |
1201 | mAv.StopTS (); |
1202 | //mTvEpg.leaveChannel(); |
1203 | //mTvEpg.leaveProgram(); |
1204 | } |
1205 | config_value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); |
1206 | if ( strcmp ( config_value, "black" ) == 0 ) { |
1207 | mAv.DisableVideoWithBlackColor(); |
1208 | } else { |
1209 | mAv.DisableVideoWithBlueColor(); |
1210 | } |
1211 | mTvAction &= ~TV_ACTION_PLAYING; |
1212 | return 0; |
1213 | } |
1214 | |
1215 | int CTv::GetATVAFCType() |
1216 | { |
1217 | return 1; |
1218 | } |
1219 | |
1220 | int CTv::GetATVSourceTimerSwitch() |
1221 | { |
1222 | return 1; |
1223 | } |
1224 | |
1225 | int CTv::getAudioChannel() |
1226 | { |
1227 | int iRet = -1; |
1228 | AM_AOUT_OutputMode_t audioChanneleMod; |
1229 | do { |
1230 | iRet = mAv.AudioGetOutputMode (&audioChanneleMod ); |
1231 | if ( AM_SUCCESS != iRet ) { |
1232 | LOGD ( "%s, audio GetOutputMode is FAILED %d\n", __FUNCTION__, iRet ); |
1233 | break; |
1234 | } |
1235 | LOGD ( "%s, jianfei.lan getAudioChannel iRet : %d audioChanneleMod %d\n", __FUNCTION__, iRet, audioChanneleMod ); |
1236 | } while ( 0 ); |
1237 | return audioChanneleMod; |
1238 | } |
1239 | |
1240 | int CTv::setAudioChannel ( int channelIdx ) |
1241 | { |
1242 | int iOutRet = 0; |
1243 | AM_AOUT_OutputMode_t audioChanneleMod; |
1244 | LOGD ( "%s, channelIdx : %d\n", __FUNCTION__, channelIdx ); |
1245 | audioChanneleMod = ( AM_AOUT_OutputMode_t ) channelIdx; |
1246 | iOutRet = mAv.AudioSetOutputMode (audioChanneleMod ); |
1247 | int aud_ch = 1; |
1248 | if (audioChanneleMod == AM_AOUT_OUTPUT_STEREO) { |
1249 | aud_ch = 1; |
1250 | } else if (audioChanneleMod == AM_AOUT_OUTPUT_DUAL_LEFT) { |
1251 | aud_ch = 2; |
1252 | } else if (audioChanneleMod == AM_AOUT_OUTPUT_DUAL_RIGHT) { |
1253 | aud_ch = 3; |
1254 | } |
1255 | CTvProgram::updateAudioChannel(m_cur_playing_prog_id, aud_ch); |
1256 | if ( AM_SUCCESS != iOutRet) { |
1257 | LOGD ( "%s, jianfei.lan TV AM_AOUT_SetOutputMode device is FAILED %d\n", __FUNCTION__, iOutRet ); |
1258 | } |
1259 | return 0; |
1260 | } |
1261 | |
1262 | int CTv::getFrontendSignalStrength() |
1263 | { |
1264 | return mFrontDev.getStrength(); |
1265 | } |
1266 | |
1267 | int CTv::getFrontendSNR() |
1268 | { |
1269 | return mFrontDev.getSNR(); |
1270 | } |
1271 | |
1272 | int CTv::getFrontendBER() |
1273 | { |
1274 | return mFrontDev.getBER(); |
1275 | } |
1276 | |
1277 | int CTv::getChannelInfoBydbID ( int dbID, channel_info_t &chan_info ) |
1278 | { |
1279 | CTvProgram prog; |
1280 | CTvChannel channel; |
1281 | Vector<sp<CTvProgram> > out; |
1282 | memset ( &chan_info, sizeof ( chan_info ), 0 ); |
1283 | chan_info.freq = 44250000; |
1284 | chan_info.uInfo.atvChanInfo.videoStd = CC_ATV_VIDEO_STD_PAL; |
1285 | chan_info.uInfo.atvChanInfo.audioStd = CC_ATV_AUDIO_STD_DK; |
1286 | static const int CVBS_ID = -1; |
1287 | if (dbID == CVBS_ID) { |
1288 | unsigned char std; |
1289 | SSMReadCVBSStd(&std); |
1290 | chan_info.uInfo.atvChanInfo.videoStd = (atv_video_std_t)std; |
1291 | chan_info.uInfo.atvChanInfo.audioStd = CC_ATV_AUDIO_STD_DK; |
1292 | chan_info.uInfo.atvChanInfo.isAutoStd = (std == CC_ATV_VIDEO_STD_AUTO) ? 1 : 0; |
1293 | return 0; |
1294 | } |
1295 | |
1296 | int ret = CTvProgram::selectByID ( dbID, prog ); |
1297 | if ( ret != 0 ) { |
1298 | LOGD ( "getChannelinfo , select dbid=%d,is not exist", dbID); |
1299 | return -1; |
1300 | } |
1301 | prog.getChannel ( channel ); |
1302 | |
1303 | if ( CTvProgram::TYPE_ATV == prog.getProgType() ) { |
1304 | chan_info.freq = channel.getFrequency(); |
1305 | chan_info.uInfo.atvChanInfo.finefreq = channel.getAfcData(); |
1306 | LOGD("%s, get channel std = %lld", __FUNCTION__, channel.getStd()); |
1307 | chan_info.uInfo.atvChanInfo.videoStd = |
1308 | ( atv_video_std_t ) CFrontEnd::stdAndColorToVideoEnum ( channel.getStd() ); |
1309 | chan_info.uInfo.atvChanInfo.audioStd = |
1310 | ( atv_audio_std_t ) CFrontEnd::stdAndColorToAudioEnum ( channel.getStd() ); |
1311 | chan_info.uInfo.atvChanInfo.isAutoStd = ((channel.getStd() & V4L2_COLOR_STD_AUTO) == V4L2_COLOR_STD_AUTO) ? 1 : 0; |
1312 | } else if ( CTvProgram::TYPE_DTV == prog.getProgType() || CTvProgram::TYPE_RADIO == prog.getProgType()) { |
1313 | chan_info.freq = channel.getFrequency(); |
1314 | chan_info.uInfo.dtvChanInfo.strength = getFrontendSignalStrength(); |
1315 | chan_info.uInfo.dtvChanInfo.quality = getFrontendSNR(); |
1316 | chan_info.uInfo.dtvChanInfo.ber = getFrontendBER(); |
1317 | } |
1318 | |
1319 | return 0; |
1320 | } |
1321 | |
1322 | bool CTv::Tv_Start_Analyze_Ts ( int channelID ) |
1323 | { |
1324 | int freq, ret; |
1325 | CTvChannel channel; |
1326 | |
1327 | AutoMutex lock ( mLock ); |
1328 | mAv.StopTS (); |
1329 | mAv.DisableVideoWithBlueColor(); |
1330 | ret = CTvChannel::selectByID ( channelID, channel ); |
1331 | if ( ret != 0 ) { |
1332 | LOGD ( "%s, CTv tv_updatats can not get freq by channel ID", __FUNCTION__ ); |
1333 | return false; |
1334 | } |
1335 | |
1336 | mTvAction |= TV_ACTION_SCANNING; |
1337 | freq = channel.getFrequency(); |
1338 | LOGD ( "%s, the freq = %d", __FUNCTION__, freq ); |
1339 | mDtvScanRunningStatus = DTV_SCAN_RUNNING_ANALYZE_CHANNEL; |
1340 | mTvScanner.setObserver ( &mTvMsgQueue ); |
1341 | mTvScanner.manualDtmbScan ( freq, freq ); //dtmb |
1342 | return true; |
1343 | } |
1344 | |
1345 | bool CTv::Tv_Stop_Analyze_Ts() |
1346 | { |
1347 | stopScanLock(); |
1348 | return true; |
1349 | } |
1350 | |
1351 | int CTv::saveATVProgramID ( int dbID ) |
1352 | { |
1353 | config_set_int ( CFG_SECTION_TV, "atv.get.program.id", dbID ); |
1354 | return 0; |
1355 | } |
1356 | |
1357 | int CTv::getATVProgramID ( void ) |
1358 | { |
1359 | return config_get_int ( CFG_SECTION_TV, "atv.get.program.id", -1 ); |
1360 | } |
1361 | |
1362 | int CTv::saveDTVProgramID ( int dbID ) |
1363 | { |
1364 | config_set_int ( CFG_SECTION_TV, "dtv.get.program.id", dbID ); |
1365 | return 0; |
1366 | } |
1367 | |
1368 | int CTv::getDTVProgramID ( void ) |
1369 | { |
1370 | return config_get_int ( CFG_SECTION_TV, "dtv.get.program.id", -1 ); |
1371 | } |
1372 | |
1373 | int CTv::getATVMinMaxFreq ( int *scanMinFreq, int *scanMaxFreq ) |
1374 | { |
1375 | int tmpVal, i = 0; |
1376 | const char *config_value; |
1377 | const char *strDelimit = ","; |
1378 | char *token = NULL; |
1379 | |
1380 | *scanMinFreq = 44250000; |
1381 | *scanMaxFreq = 868250000; |
1382 | |
1383 | config_value = config_get_str ( CFG_SECTION_ATV, "atv.get.min.max.freq", "null" ); |
1384 | if ( strcmp ( config_value, "null" ) == 0 ) { |
1385 | LOGD ( "%s, atv.get.min.max.freq not set config\n", __FUNCTION__ ); |
1386 | return -1; |
1387 | } |
1388 | |
1389 | char data_str[512] = {0}; |
1390 | strncpy ( data_str, config_value, sizeof ( data_str ) - 1 ); |
1391 | |
1392 | char *pSave; |
1393 | token = strtok_r ( data_str, strDelimit, &pSave); |
1394 | sscanf ( token, "%d", scanMinFreq ); |
1395 | token = strtok_r ( NULL, strDelimit , &pSave); |
1396 | if ( token != NULL ) { |
1397 | sscanf ( token, "%d", scanMaxFreq ); |
1398 | } |
1399 | return 0; |
1400 | } |
1401 | |
1402 | int CTv::IsDVISignal() |
1403 | { |
1404 | return ( ( TVIN_SIG_FMT_NULL != mSigDetectThread.getCurSigInfo().fmt ) && ( mSigDetectThread.getCurSigInfo().reserved & 0x1 ) ); |
1405 | } |
1406 | |
1407 | int CTv::getHDMIFrameRate() |
1408 | { |
1409 | int ConstRate[5] = {24, 25, 30, 50, 60}; |
1410 | float ConstRateDiffHz[5] = {0.5, 0.5, 0.5, 2, 2}; |
1411 | int fps = mSigDetectThread.getCurSigInfo().fps; |
1412 | for (int i = 0; i < 5; i++) { |
1413 | if (abs(ConstRate[i] - fps) < ConstRateDiffHz[i]) |
1414 | fps = ConstRate[i]; |
1415 | } |
1416 | return fps; |
1417 | } |
1418 | |
1419 | tv_source_input_t CTv::GetLastSourceInput ( void ) |
1420 | { |
1421 | return m_last_source_input; |
1422 | } |
1423 | |
1424 | int CTv::isVgaFmtInHdmi ( void ) |
1425 | { |
1426 | tvin_sig_fmt_t fmt = mSigDetectThread.getCurSigInfo().fmt; |
1427 | |
1428 | if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI ) { |
1429 | return -1; |
1430 | } |
1431 | return CTvin::isVgaFmtInHdmi ( fmt ); |
1432 | } |
1433 | |
1434 | int CTv::isSDFmtInHdmi ( void ) |
1435 | { |
1436 | tvin_sig_fmt_t fmt = mSigDetectThread.getCurSigInfo().fmt; |
1437 | |
1438 | if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI ) { |
1439 | return -1; |
1440 | } |
1441 | return CTvin::isSDFmtInHdmi ( fmt ); |
1442 | } |
1443 | |
1444 | void CTv::print_version_info ( void ) |
1445 | { |
1446 | // print tvapi version info |
1447 | LOGD ( "libtvservice git branch:%s\n", tvservice_get_git_branch_info() ); |
1448 | LOGD ( "libtvservice git version:%s\n", tvservice_get_git_version_info() ); |
1449 | LOGD ( "libtvservice Last Changed:%s\n", tvservice_get_last_chaned_time_info() ); |
1450 | LOGD ( "libtvservice Last Build:%s\n", tvservice_get_build_time_info() ); |
1451 | LOGD ( "libtvservice Builer Name:%s\n", tvservice_get_build_name_info() ); |
1452 | LOGD ( "libtvservice board version:%s\n", tvservice_get_board_version_info() ); |
1453 | LOGD ( "\n\n"); |
1454 | // print dvb version info |
1455 | LOGD ( "libdvb git branch:%s\n", dvb_get_git_branch_info() ); |
1456 | LOGD ( "libdvb git version:%s\n", dvb_get_git_version_info() ); |
1457 | LOGD ( "libdvb Last Changed:%s\n", dvb_get_last_chaned_time_info() ); |
1458 | LOGD ( "libdvb Last Build:%s\n", dvb_get_build_time_info() ); |
1459 | LOGD ( "libdvb Builer Name:%s\n", dvb_get_build_name_info() ); |
1460 | } |
1461 | |
1462 | int CTv::Tvin_GetTvinConfig ( void ) |
1463 | { |
1464 | const char *config_value; |
1465 | |
1466 | config_value = config_get_str ( CFG_SECTION_TV, "tvin.kernelpet_disable", "null" ); |
1467 | if ( strcmp ( config_value, "disable" ) == 0 ) { |
1468 | gTvinConfig.kernelpet_disable = true; |
1469 | } else { |
1470 | gTvinConfig.kernelpet_disable = false; |
1471 | } |
1472 | |
1473 | config_value = config_get_str ( CFG_SECTION_TV, "tvin.kernelpet.timeout", "null" ); |
1474 | gTvinConfig.userpet_timeout = ( unsigned int ) strtol ( config_value, NULL, 10 ); |
1475 | |
1476 | if ( gTvinConfig.kernelpet_timeout <= 0 || gTvinConfig.kernelpet_timeout > 40 ) { |
1477 | gTvinConfig.kernelpet_timeout = 10; |
1478 | } |
1479 | |
1480 | config_value = config_get_str ( CFG_SECTION_TV, "tvin.userpet", "null" ); |
1481 | if ( strcmp ( config_value, "enable" ) == 0 ) { |
1482 | gTvinConfig.userpet = true; |
1483 | } else { |
1484 | gTvinConfig.userpet = false; |
1485 | } |
1486 | |
1487 | config_value = config_get_str ( CFG_SECTION_TV, "tvin.userpet.timeout", "null" ); |
1488 | gTvinConfig.userpet_timeout = ( unsigned int ) strtol ( config_value, NULL, 10 ); |
1489 | |
1490 | if ( gTvinConfig.userpet_timeout <= 0 || gTvinConfig.userpet_timeout > 100 ) { |
1491 | gTvinConfig.userpet_timeout = 10; |
1492 | } |
1493 | |
1494 | config_value = config_get_str ( CFG_SECTION_TV, "tvin.userpet.reset", "null" ); |
1495 | if ( strcmp ( config_value, "disable" ) == 0 ) { |
1496 | gTvinConfig.userpet_reset = 0; |
1497 | } else { |
1498 | gTvinConfig.userpet_reset = 1; |
1499 | } |
1500 | return 0; |
1501 | } |
1502 | |
1503 | TvRunStatus_t CTv::GetTvStatus() |
1504 | { |
1505 | Mutex::Autolock _l ( mLock ); |
1506 | return mTvStatus; |
1507 | } |
1508 | |
1509 | int CTv::OpenTv ( void ) |
1510 | { |
1511 | const char *value; |
1512 | Tv_Spread_Spectrum(); |
1513 | //reboot system by fbc setting. |
1514 | value = config_get_str ( CFG_SECTION_TV, "fbc.get.panelinfo", "null" ); |
1515 | LOGD("open tv, get fbc panel info:%s\n", value); |
1516 | if ( strcmp ( value, "edid" ) == 0 ) { |
1517 | reboot_sys_by_fbc_edid_info(); |
1518 | } else if ( strcmp ( value, "uart" ) == 0 ) { |
1519 | reboot_sys_by_fbc_uart_panel_info(fbcIns); |
1520 | } |
1521 | |
1522 | mTvin.Tvin_LoadSourceInputToPortMap(); |
1523 | |
1524 | SSMHandlePreCopying(); |
1525 | if ( SSMDeviceMarkCheck() < 0 ) { |
1526 | SSMRestoreDeviceMarkValues(); |
1527 | Tv_SSMRestoreDefaultSetting(); |
1528 | } |
1529 | mTvin.OpenTvin(); |
1530 | mTvin.init_vdin(); |
1531 | mTvin.Tv_init_afe(); |
1532 | mVpp.Vpp_Init(getPqDbPath()); |
1533 | TvAudioOpen(); |
1534 | SetAudioVolDigitLUTTable(SOURCE_MPEG); |
1535 | |
1536 | SSMSetHDCPKey(); |
1537 | system ( "/system/bin/dec" ); |
1538 | |
1539 | //set color filter |
1540 | // SetFileAttrValue ( "/sys/module/amvideo/parameters/filt_mode", "0x2100" ); |
1541 | value = config_get_str ( CFG_SECTION_TV, "tvin.autoset.displayfreq", "null" ); |
1542 | if ( strcmp ( value, "enable" ) == 0 ) { |
1543 | mAutoSetDisplayFreq = true; |
1544 | } else { |
1545 | mAutoSetDisplayFreq = false; |
1546 | } |
1547 | |
1548 | Tv_HandeHDMIEDIDFilePathConfig(); |
1549 | |
1550 | value = config_get_str ( CFG_SECTION_TV, "ssm.handle.hdmi.edid.en", "null" ); |
1551 | if ( strtoul(value, NULL, 10) == 1 ) { |
1552 | LOGD( "%s, get config \"%s\" is \"%s\".\n", __FUNCTION__, "ssm.handle.hdmi.edid.en", value ); |
1553 | //get hdmi edid use mode |
1554 | char prop_value[256] = {0}; |
1555 | char *pEdid = NULL; |
1556 | property_get( "ubootenv.var.outputmode", prop_value, "null" ); |
1557 | LOGD( "%s, get property \"%s\" is \"%s\".\n", __FUNCTION__, "ubootenv.var.outputmode", prop_value ); |
1558 | |
1559 | if ( strcmp ( prop_value, "null" ) != 0 ) |
1560 | pEdid = prop_value; |
1561 | else |
1562 | pEdid = "hdmi_edid";//set default hdmi edid |
1563 | |
1564 | config_set_str ( CFG_SECTION_TV, CS_HDMI_EDID_USE_CFG, pEdid ); |
1565 | //set file's path for hdmi edid of each port |
1566 | for ( int i = 1; i <= SSM_HDMI_PORT_MAX; i++ ) { |
1567 | char edid_path[256] = {0}; |
1568 | char edid_path_cfg[256] = {0}; |
1569 | sprintf ( edid_path, "/system/etc/%s_port%d.bin", pEdid, i ); |
1570 | sprintf ( edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i ); |
1571 | config_set_str ( CFG_SECTION_TV, edid_path_cfg, edid_path ); |
1572 | } |
1573 | |
1574 | mSetHdmiEdid = true; |
1575 | } |
1576 | |
1577 | Tvin_GetTvinConfig(); |
1578 | m_last_source_input = SOURCE_INVALID; |
1579 | m_source_input = SOURCE_INVALID; |
1580 | m_mode_3d = VIDEO_3D_MODE_DISABLE; |
1581 | m_hdmi_sampling_rate = 0; |
1582 | int8_t blackout_enable; |
1583 | SSMReadBlackoutEnable(&blackout_enable); |
1584 | m_blackout_enable = blackout_enable; |
1585 | |
1586 | //dtv init |
1587 | //int rt = -1; |
1588 | //opendemux(); |
1589 | //rt = mFrontDev.Open(FE_ANALOG); |
1590 | //mFrontDev.autoLoadFE(); |
1591 | //rt = mFrontDev.Open(FE_ANALOG); |
1592 | AM_DMX_OpenPara_t para_dmx; |
1593 | memset ( ¶_dmx, 0, sizeof ( AM_DMX_OpenPara_t ) ); |
1594 | mTvDmx.Open(para_dmx ); |
1595 | mTvDmx.SetSource (AM_DMX_SRC_TS2); |
1596 | mAv.Open(); |
1597 | //mTvEpg.Init ( 0, 0, 1, "eng zho chi", "GB2312" ); |
1598 | resetDmxAndAvSource(); |
1599 | mSourceConnectDetectThread.startDetect(); |
1600 | |
1601 | if (SSMReadSerialCMDSwitchValue() == 1) { |
1602 | SetSerialSwitch(SERIAL_A, 1); |
1603 | } |
1604 | ClearAnalogFrontEnd(); |
1605 | |
1606 | mTvStatus = TV_OPEN_ED; |
1607 | |
1608 | mHDMIRxCEC.start(); |
1609 | mAutoPQparam.startAutoPQ(CTvin::Tvin_SourceInputToSourceInputType(SOURCE_MPEG)); |
1610 | return 0; |
1611 | } |
1612 | |
1613 | int CTv::CloseTv ( void ) |
1614 | { |
1615 | LOGD ( "tv close"); |
1616 | mSigDetectThread.stopDetect(); |
1617 | if (mpUpgradeFBC != NULL) { |
1618 | mpUpgradeFBC->stop(); |
1619 | } |
1620 | mTvin.Tv_uninit_afe(); |
1621 | mTvin.uninit_vdin(); |
1622 | mVpp.Vpp_Uninit(); |
1623 | TvMisc_DisableWDT ( gTvinConfig.userpet ); |
1624 | mTvStatus = TV_CLOSE_ED; |
1625 | return 0; |
1626 | } |
1627 | |
1628 | int CTv::StartTvLock () |
1629 | { |
1630 | LOGD ( "%s, tv start status = %d", __FUNCTION__, mTvStatus); |
1631 | if (mTvStatus == TV_START_ED) |
1632 | return 0; |
1633 | |
1634 | Mutex::Autolock _l ( mLock ); |
1635 | mTvAction |= TV_ACTION_STARTING; |
1636 | mAv.ClearVideoBuffer(); |
1637 | SwitchAVOutBypass(0); |
1638 | InitSetTvAudioCard(); |
1639 | SetAudioMuteForTv(CC_AUDIO_MUTE); |
1640 | mFrontDev.Open(FE_ANALOG); |
1641 | mFrontDev.autoLoadFE(); |
1642 | mSigDetectThread.startDetect(); |
1643 | mTvMsgQueue.startMsgQueue(); |
1644 | resetDmxAndAvSource(); |
1645 | SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt); |
1646 | TvMisc_EnableWDT ( gTvinConfig.kernelpet_disable, gTvinConfig.userpet, gTvinConfig.kernelpet_timeout, gTvinConfig.userpet_timeout, gTvinConfig.userpet_reset ); |
1647 | am_phase_t am_phase; |
1648 | if (mVpp.getPqData()->PQ_GetPhaseArray ( &am_phase ) == 0 ) { |
1649 | mTvin.TvinApi_SetCompPhase(am_phase); |
1650 | } |
1651 | mTvin.TvinApi_SetCompPhaseEnable ( 1 ); |
1652 | mTvin.VDIN_EnableRDMA ( 1 ); |
1653 | |
1654 | //win pos |
1655 | tvin_window_pos_t win_pos; |
1656 | Vpp_GetDisplayResolutionInfo(&win_pos); |
1657 | SetPreviewWindow ( win_pos ); |
1658 | |
1659 | mTvin.Tvin_RemovePath ( TV_PATH_TYPE_TVIN ); |
1660 | if ( mTvin.Tvin_RemovePath ( TV_PATH_TYPE_DEFAULT ) ) { |
1661 | mTvin.Tvin_AddPath ( TV_PATH_DECODER_NEW3D_WITHOUTPPMGR_AMVIDEO ); |
1662 | } |
1663 | |
1664 | mAv.SetVideoWindow (0, 0, 0, 0 ); |
1665 | |
1666 | mTvAction &= ~TV_ACTION_STARTING; |
1667 | mTvStatus = TV_START_ED; |
1668 | return 0; |
1669 | } |
1670 | |
1671 | int CTv::DoInstabootSuspend() |
1672 | { |
1673 | CTvDatabase::GetTvDb()->UnInitTvDb(); |
1674 | CTvSettingdoSuspend(); |
1675 | mVpp.doSuspend(); |
1676 | LOGD("%s, \n", __FUNCTION__); |
1677 | return 0; |
1678 | } |
1679 | |
1680 | int CTv::DoInstabootResume() |
1681 | { |
1682 | CTvDatabase::GetTvDb()->InitTvDb(TV_DB_PATH); |
1683 | CTvSettingdoResume(); |
1684 | mVpp.doResume(); |
1685 | LOGD("%s, \n", __FUNCTION__); |
1686 | return 0; |
1687 | } |
1688 | |
1689 | int CTv::DoSuspend(int type) |
1690 | { |
1691 | if (type == 1) { |
1692 | DoInstabootSuspend(); |
1693 | } |
1694 | return 0; |
1695 | } |
1696 | |
1697 | int CTv::DoResume(int type) |
1698 | { |
1699 | if (type == 1) { |
1700 | DoInstabootResume(); |
1701 | } |
1702 | return 0; |
1703 | } |
1704 | |
1705 | int CTv::StopTvLock ( void ) |
1706 | { |
1707 | LOGD("%s, call Tv_Stop status = %d \n", __FUNCTION__, mTvStatus); |
1708 | const char *value; |
1709 | Mutex::Autolock _l ( mLock ); |
1710 | mAv.DisableVideoWithBlackColor(); |
1711 | mVpp.LoadVppSettings ( SOURCE_TYPE_MPEG, TVIN_SIG_FMT_NULL, INDEX_2D, TVIN_TFMT_2D ); |
1712 | //we should stop audio first for audio mute. |
1713 | mTvAction |= TV_ACTION_STOPING; |
1714 | mTvin.Tvin_StopDecoder(); |
1715 | mTvin.Tvin_RemovePath ( TV_PATH_TYPE_TVIN ); |
1716 | mTvin.VDIN_ClosePort(); |
1717 | mTvMsgQueue.clearMsg(); |
1718 | mSigDetectThread.requestAndWaitPauseDetect(); |
1719 | //stop scan if scanning |
1720 | stopScan(); |
1721 | mFrontDev.SetAnalogFrontEndTimerSwitch(0); |
1722 | //first stop play(if playing) |
1723 | stopPlaying(); |
1724 | // |
1725 | setAudioChannel(AM_AOUT_OUTPUT_STEREO); |
1726 | mTvin.setMpeg2Vdin(0); |
1727 | mAv.setLookupPtsForDtmb(0); |
1728 | SwitchAVOutBypass(0); |
1729 | tv_audio_channel_e audio_channel = mTvin.Tvin_GetInputSourceAudioChannelIndex (SOURCE_MPEG); |
1730 | AudioLineInSelectChannel( audio_channel ); |
1731 | AudioCtlUninit(); |
1732 | SetAudioVolDigitLUTTable(SOURCE_MPEG); |
1733 | Tv_SetAudioInSource(SOURCE_MPEG); |
1734 | tvin_window_pos_t win_pos; |
1735 | Vpp_GetDisplayResolutionInfo(&win_pos); |
1736 | SetPreviewWindow (win_pos ); |
1737 | //mVpp.LoadVppSettings ( SOURCE_TYPE_MPEG, TVIN_SIG_FMT_NULL, INDEX_2D, TVIN_TFMT_2D ); |
1738 | SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(SOURCE_MPEG) ), CTvin::Tvin_SourceInputToSourceInputType(SOURCE_MPEG), mSigDetectThread.getCurSigInfo().fmt); |
1739 | RefreshAudioMasterVolume ( SOURCE_MPEG ); |
1740 | mVpp.VPP_SetScalerPathSel(0); |
1741 | mVpp.VPP_SetVideoCrop ( 0, 0, 0, 0 ); |
1742 | m_last_source_input = SOURCE_INVALID; |
1743 | m_source_input = SOURCE_INVALID; |
1744 | mFrontDev.Close(); |
1745 | mTvAction &= ~TV_ACTION_STOPING; |
1746 | mTvStatus = TV_STOP_ED; |
1747 | if ( Get2d4gHeadsetEnable() == 1 ) { |
1748 | property_set("audio.tv_open.flg", "0"); |
1749 | } |
1750 | |
1751 | Tv_SetDDDRCMode(SOURCE_MPEG); |
1752 | mAv.DisableVideoWithBlackColor(); |
1753 | //mAutoPQparam.startAutoPQ(CTvin::Tvin_SourceInputToSourceInputType(SOURCE_MPEG)); |
1754 | mAv.ClearVideoBuffer(); |
1755 | mAv.EnableVideoBlackout(); |
1756 | SetAudioMuteForTv ( CC_AUDIO_UNMUTE ); |
1757 | return 0; |
1758 | } |
1759 | |
1760 | const char *CTv::getPqDbPath() |
1761 | { |
1762 | return config_get_str(CFG_SECTION_TV, "pq_db_path", "/param/pq.db"); |
1763 | } |
1764 | |
1765 | int CTv::Tv_MiscSetBySource ( tv_source_input_t source_input ) |
1766 | { |
1767 | int ret = -1; |
1768 | |
1769 | switch ( source_input ) { |
1770 | case SOURCE_TV: |
1771 | mVpp.VPP_SetScalerPathSel(1); |
1772 | ret = SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "4" ); |
1773 | break; |
1774 | |
1775 | case SOURCE_HDMI1: |
1776 | case SOURCE_HDMI2: |
1777 | case SOURCE_HDMI3: |
1778 | mVpp.VPP_SetScalerPathSel(0); |
1779 | //ret = mVpp.Tv_SavePanoramaMode ( VPP_PANORAMA_MODE_FULL, SOURCE_TYPE_HDMI ); |
1780 | ret |= SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "5" ); |
1781 | break; |
1782 | |
1783 | case SOURCE_DTV: |
1784 | mVpp.VPP_SetScalerPathSel(0); |
1785 | |
1786 | case SOURCE_AV1: |
1787 | case SOURCE_AV2: |
1788 | case SOURCE_VGA: |
1789 | mVpp.VPP_SetScalerPathSel(1); |
1790 | ret |= SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "5" ); |
1791 | break; |
1792 | |
1793 | case SOURCE_SVIDEO: |
1794 | case SOURCE_IPTV: |
1795 | mVpp.VPP_SetScalerPathSel(1); |
1796 | default: |
1797 | mVpp.VPP_SetScalerPathSel(0); |
1798 | ret |= SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "5" ); |
1799 | break; |
1800 | } |
1801 | return ret; |
1802 | } |
1803 | |
1804 | int CTv::SetSourceSwitchInput (tv_source_input_t source_input ) |
1805 | { |
1806 | Mutex::Autolock _l ( mLock ); |
1807 | LOGD ( "%s, source input = %d", __FUNCTION__, source_input ); |
1808 | tv_source_input_t cur_source_input = m_source_input; |
1809 | tvin_port_t cur_port; |
1810 | |
1811 | Tv_SetDDDRCMode(source_input); |
1812 | if (source_input == cur_source_input ) { |
1813 | LOGW ( "%s,same input change display mode", __FUNCTION__ ); |
1814 | return 0; |
1815 | } |
1816 | |
1817 | //if HDMI, need to set EDID of each port |
1818 | if (mSetHdmiEdid) { |
1819 | int tmp_ret = 0; |
1820 | switch ( source_input ) { |
1821 | case SOURCE_HDMI1: |
1822 | tmp_ret = SSMSetHDMIEdid(1); |
1823 | break; |
1824 | case SOURCE_HDMI2: |
1825 | tmp_ret = SSMSetHDMIEdid(2); |
1826 | break; |
1827 | case SOURCE_HDMI3: |
1828 | tmp_ret = SSMSetHDMIEdid(3); |
1829 | break; |
1830 | default: |
1831 | tmp_ret = -1; |
1832 | break; |
1833 | } |
1834 | if (tmp_ret < 0) |
1835 | LOGE ( "%s, do not set hdmi port%d edid.ret=%d", __FUNCTION__, source_input - 4, tmp_ret ); |
1836 | } |
1837 | mTvAction |= TV_ACTION_SOURCE_SWITCHING; |
1838 | m_cur_playing_prog_id = -1; |
1839 | // |
1840 | SetAudioMuteForTv(CC_AUDIO_MUTE); |
1841 | mSigDetectThread.requestAndWaitPauseDetect(); |
1842 | //const char *config_value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); |
1843 | //if ( strcmp ( config_value, "black" ) == 0 ) { |
1844 | // mAv.DisableVideoWithBlackColor(); |
1845 | //} else { |
1846 | // mAv.DisableVideoWithBlueColor(); |
1847 | //} |
1848 | mAv.DisableVideoWithBlackColor(); |
1849 | //enable blackout, when play,disable it |
1850 | mAv.EnableVideoBlackout(); |
1851 | //set front dev mode |
1852 | if ( source_input == SOURCE_TV ) { |
1853 | mFrontDev.Close(); |
1854 | mFrontDev.Open(FE_ANALOG); |
1855 | mFrontDev.SetAnalogFrontEndTimerSwitch(GetATVSourceTimerSwitch()); |
1856 | //mFrontDev.setMode ( FE_ANALOG ); |
1857 | } else if ( source_input == SOURCE_DTV ) { |
1858 | mFrontDev.Close(); |
1859 | mFrontDev.Open(FE_ANALOG); |
1860 | //mFrontDev.setMode ( FE_DTMB); |
1861 | mFrontDev.SetAnalogFrontEndTimerSwitch(0); |
1862 | } else { |
1863 | mFrontDev.Close(); |
1864 | mFrontDev.SetAnalogFrontEndTimerSwitch(0); |
1865 | } |
1866 | |
1867 | //ok |
1868 | m_last_source_input = m_source_input; |
1869 | m_source_input = source_input; |
1870 | SSMSaveSourceInput ( source_input ); |
1871 | |
1872 | tv_source_input_t pre_source_input = cur_source_input;//change |
1873 | cur_source_input = source_input; |
1874 | |
1875 | SetAudioVolumeCompensationVal ( 0 ); |
1876 | |
1877 | if ( source_input == SOURCE_DTV ) { |
1878 | //we should stop audio first for audio mute. |
1879 | SwitchAVOutBypass(0); |
1880 | tv_audio_channel_e audio_channel = mTvin.Tvin_GetInputSourceAudioChannelIndex (SOURCE_MPEG); |
1881 | AudioLineInSelectChannel( audio_channel ); |
1882 | AudioCtlUninit(); |
1883 | SetAudioVolDigitLUTTable(SOURCE_MPEG); |
1884 | // |
1885 | mTvin.Tvin_StopDecoder(); |
1886 | mTvin.Tvin_RemovePath ( TV_PATH_TYPE_TVIN ); |
1887 | mTvin.VDIN_ClosePort(); |
1888 | //double confirm we set the main volume lut buffer to mpeg |
1889 | RefreshAudioMasterVolume ( SOURCE_MPEG ); |
1890 | RefreshSrsEffectAndDacGain(); |
1891 | SetCustomEQGain(); |
1892 | mTvin.setMpeg2Vdin(1); |
1893 | mAv.setLookupPtsForDtmb(1); |
1894 | //mVpp.LoadVppSettings ( SOURCE_TYPE_DTV, TVIN_SIG_FMT_NULL, INDEX_2D, TVIN_TFMT_2D ); |
1895 | //mAutoPQparam.startAutoPQ(CTvin::Tvin_SourceInputToSourceInputType(SOURCE_DTV)); |
1896 | Tv_SetAudioInSource ( source_input ); |
1897 | } else { |
1898 | mAutoPQparam.stopAutoPQ(); |
1899 | mTvin.setMpeg2Vdin(0); |
1900 | mAv.setLookupPtsForDtmb(0); |
1901 | mTvin.Tvin_AddPath ( TV_PATH_VDIN_NEW3D_WITHOUTPPMGR_AMVIDEO ); |
1902 | } |
1903 | cur_port = mTvin.Tvin_GetSourcePortBySourceInput ( cur_source_input ); |
1904 | Tv_MiscSetBySource ( source_input ); |
1905 | |
1906 | //only DTV->TVIN or TVIN->DTV need start resource detect thread |
1907 | if ( ( pre_source_input == SOURCE_DTV || cur_source_input == SOURCE_DTV ) && |
1908 | ( cur_source_input != pre_source_input ) ) { |
1909 | LOGD ( "%s, dtv need resource detect\n", __FUNCTION__ ); |
1910 | int isNeedCheckD2D3 = ( gTvinConfig.memory512m) ? 1 : 0; |
1911 | static int sigchkcnt = 0; |
1912 | while ( true ) { |
1913 | if ( ( mTvin.Tvin_CheckPathActive ( TV_PATH_TYPE_DEFAULT, isNeedCheckD2D3 ) == TV_PATH_STATUS_INACTIVE ) |
1914 | && ( mTvin.Tvin_CheckPathActive ( TV_PATH_TYPE_TVIN, isNeedCheckD2D3 ) == TV_PATH_STATUS_INACTIVE ) ) { |
1915 | LOGD("%s, path check is ok, and break\n", __FUNCTION__); |
1916 | break; |
1917 | } else { |
1918 | if (sigchkcnt++ > 20) { |
1919 | sigchkcnt = 0; |
1920 | break; |
1921 | } |
1922 | LOGW ( "%s,resource is busy.", __FUNCTION__); |
1923 | } |
1924 | } |
1925 | } |
1926 | |
1927 | if ( source_input != SOURCE_DTV ) { |
1928 | // Uninit data |
1929 | UnInitTvAudio(); |
1930 | if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3 || |
1931 | source_input == SOURCE_MPEG || source_input == SOURCE_DTV ) { |
1932 | SwitchAVOutBypass(0); |
1933 | } else { |
1934 | SwitchAVOutBypass(1); |
1935 | } |
1936 | |
1937 | tv_audio_channel_e audio_channel = mTvin.Tvin_GetInputSourceAudioChannelIndex (source_input); |
1938 | AudioLineInSelectChannel( audio_channel ); |
1939 | |
1940 | Tv_SetAudioInSource ( source_input ); |
1941 | if ( source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3 ) { |
1942 | m_hdmi_sampling_rate = 0; |
1943 | m_hdmi_audio_data = 0; |
1944 | } else { |
1945 | InitTvAudio ( 48000, CC_IN_USE_I2S_DEVICE); |
1946 | HanldeAudioInputSr(-1); |
1947 | } |
1948 | //=========================================== |
1949 | if ( mTvin.SwitchPort ( cur_port ) == 0 ) { //ok |
1950 | //========================================== |
1951 | unsigned char std; |
1952 | SSMReadCVBSStd(&std); |
1953 | int fmt = CFrontEnd::stdEnumToCvbsFmt (std, CC_ATV_AUDIO_STD_AUTO); |
1954 | mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt ); |
1955 | |
1956 | //for HDMI source connect detect |
1957 | mTvin.VDIN_OpenHDMIPinMuxOn(true); |
1958 | mVpp.Vpp_ResetLastVppSettingsSourceType(); |
1959 | //========================================== |
1960 | m_sig_stable_nums = 0; |
1961 | mSigDetectThread.setObserver ( this ); |
1962 | mSigDetectThread.initSigState(); |
1963 | int resumeLater = 0; |
1964 | if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) { |
1965 | resumeLater = 1000; |
1966 | } else { |
1967 | resumeLater = 1500; |
1968 | } |
1969 | mSigDetectThread.setVdinNoSigCheckKeepTimes(150, true); |
1970 | mSigDetectThread.resumeDetect(resumeLater); |
1971 | } |
1972 | } |
1973 | |
1974 | Tv_SetAudioSourceType(source_input); |
1975 | RefreshAudioMasterVolume(source_input); |
1976 | Tv_SetAudioOutputSwap_Type(source_input); |
1977 | //Tv_ADCDigitalCapture_Volume(); |
1978 | Tv_SetAVOutPut_Input_gain(source_input); |
1979 | |
1980 | mTvAction &= ~ TV_ACTION_SOURCE_SWITCHING; |
1981 | return 0; |
1982 | } |
1983 | |
1984 | void CTv::onSigToStable() |
1985 | { |
1986 | if (mAutoSetDisplayFreq) { |
1987 | int freq = 60; |
1988 | if (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) { |
1989 | int fps = getHDMIFrameRate(); |
1990 | LOGD("onSigToStable HDMI fps = %d", fps); |
1991 | if ((30 == fps) || (60 == fps)) { |
1992 | freq = 60; |
1993 | } else { |
1994 | freq = 50; |
1995 | } |
1996 | } else if ( CTvin::Tvin_is50HzFrameRateFmt ( mSigDetectThread.getCurSigInfo().fmt ) ) { |
1997 | freq = 50; |
1998 | } |
1999 | |
2000 | mTvin.VDIN_SetDisplayVFreq ( freq, mAv.getVideoDisplayResolution(), mHdmiOutFbc ); |
2001 | LOGD ( "%s, SetDisplayVFreq %dHZ.", __FUNCTION__, freq); |
2002 | } |
2003 | //showbo mark hdmi auto 3d, tran fmt is 3d, so switch to 3d |
2004 | |
2005 | mVpp.LoadVppSettings (CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt ); |
2006 | |
2007 | if ( m_win_mode == PREVIEW_WONDOW ) { |
2008 | mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2); |
2009 | mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_FULL_STRETCH ); |
2010 | } else { |
2011 | SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt); |
2012 | } |
2013 | m_sig_stable_nums = 0; |
2014 | } |
2015 | |
2016 | void CTv::onSigStillStable() |
2017 | { |
2018 | if ( m_sig_stable_nums == 20) { |
2019 | tvin_info_t info = mSigDetectThread.getCurSigInfo(); |
2020 | TvEvent::SignalInfoEvent ev; |
2021 | ev.mTrans_fmt = info.trans_fmt; |
2022 | ev.mFmt = info.fmt; |
2023 | ev.mStatus = info.status; |
2024 | ev.mReserved = getHDMIFrameRate(); |
2025 | sendTvEvent ( ev ); |
2026 | } |
2027 | if (m_sig_stable_nums == 2) { |
2028 | LOGD("still stable , to start decoder"); |
2029 | int startdec_status = mTvin.Tvin_StartDecoder ( mSigDetectThread.getCurSigInfo() ); |
2030 | if ( startdec_status == 0 ) { //showboz codes from start decode fun |
2031 | const char *value = config_get_str ( CFG_SECTION_TV, "tvin.db.reg.en", "null" ); |
2032 | if ( strcmp ( value, "enable" ) == 0 ) { |
2033 | usleep ( 20 * 1000 ); |
2034 | Tvin_SetPLLValues (); |
2035 | usleep ( 20 * 1000 ); |
2036 | SetCVD2Values (); |
2037 | } |
2038 | } |
2039 | } |
2040 | if ( m_sig_stable_nums == 3) { |
2041 | LOGD("still stable , to unmute audio/video"); |
2042 | CMessage msg; |
2043 | msg.mDelayMs = 0; |
2044 | msg.mType = CTvMsgQueue::TV_MSG_ENABLE_VIDEO_LATER; |
2045 | msg.mpPara[0] = 2; |
2046 | mTvMsgQueue.sendMsg ( msg ); |
2047 | m_hdmi_audio_data = 0; |
2048 | } |
2049 | m_sig_stable_nums++; |
2050 | } |
2051 | |
2052 | void CTv::onEnableVideoLater(int framecount) |
2053 | { |
2054 | LOGD("onEnableVideoLater framecount = %d", framecount); |
2055 | mAv.EnableVideoWhenVideoPlaying(2); |
2056 | //if(CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI ){ |
2057 | if (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI ) { |
2058 | SetAudioMuteForTv ( CC_AUDIO_UNMUTE ); |
2059 | Tv_SetAudioInSource(m_source_input); |
2060 | //} |
2061 | } |
2062 | } |
2063 | |
2064 | void CTv::Tv_SetAVOutPut_Input_gain(tv_source_input_t source_input) |
2065 | { |
2066 | int nPgaValueIndex = 0; |
2067 | int nAdcValueIndex = 0; |
2068 | int nDdcValueIndex = 0; |
2069 | int tmpAvoutBufPtr[9]; |
2070 | |
2071 | if (GetAvOutGainBuf_Cfg(tmpAvoutBufPtr) != 0) { |
2072 | GetDefaultAvOutGainBuf(tmpAvoutBufPtr); |
2073 | } |
2074 | |
2075 | switch (source_input) { |
2076 | case SOURCE_AV1: |
2077 | case SOURCE_AV2: |
2078 | nPgaValueIndex = 0; |
2079 | nAdcValueIndex = 1; |
2080 | nDdcValueIndex = 2; |
2081 | break; |
2082 | case SOURCE_HDMI1: |
2083 | case SOURCE_HDMI2: |
2084 | case SOURCE_HDMI3: |
2085 | case SOURCE_DTV: |
2086 | case SOURCE_MPEG: |
2087 | nPgaValueIndex = 3; |
2088 | nAdcValueIndex = 4; |
2089 | nDdcValueIndex = 5; |
2090 | break; |
2091 | case SOURCE_TV: |
2092 | nPgaValueIndex = 6; |
2093 | nAdcValueIndex = 7; |
2094 | nDdcValueIndex = 8; |
2095 | break; |
2096 | default: |
2097 | break; |
2098 | } |
2099 | |
2100 | SetPGA_IN_Value(tmpAvoutBufPtr[nPgaValueIndex]); |
2101 | SetADC_Digital_Capture_Volume(tmpAvoutBufPtr[nAdcValueIndex]); |
2102 | SetDAC_Digital_PlayBack_Volume(tmpAvoutBufPtr[nDdcValueIndex]); |
2103 | } |
2104 | |
2105 | void CTv::onSigStableToUnstable() |
2106 | { |
2107 | LOGD ( "%s, stable to unstable\n", __FUNCTION__); |
2108 | SetAudioMuteForTv(CC_AUDIO_MUTE); |
2109 | mAv.DisableVideoWithBlackColor(); |
2110 | mTvin.Tvin_StopDecoder(); |
2111 | } |
2112 | |
2113 | void CTv::onSigStableToUnSupport() |
2114 | { |
2115 | SetAudioMuteForTv(CC_AUDIO_MUTE); |
2116 | mAv.DisableVideoWithBlackColor(); |
2117 | mTvin.Tvin_StopDecoder(); |
2118 | |
2119 | tvin_info_t info = mSigDetectThread.getCurSigInfo(); |
2120 | TvEvent::SignalInfoEvent ev; |
2121 | ev.mTrans_fmt = info.trans_fmt; |
2122 | ev.mFmt = info.fmt; |
2123 | ev.mStatus = info.status; |
2124 | ev.mReserved = info.reserved; |
2125 | sendTvEvent ( ev ); |
2126 | LOGD ( "%s, Enable blackscreen for signal change in StableToUnSupport!", __FUNCTION__ ); |
2127 | } |
2128 | |
2129 | void CTv::onSigStableToNoSig() |
2130 | { |
2131 | SetAudioMuteForTv(CC_AUDIO_MUTE); |
2132 | const char *value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); |
2133 | if ( strcmp ( value, "black" ) == 0 ) { |
2134 | mAv.DisableVideoWithBlackColor(); |
2135 | } else { |
2136 | mAv.DisableVideoWithBlueColor(); |
2137 | } |
2138 | //SetAudioMuteForTv(CC_AUDIO_MUTE); |
2139 | mTvin.Tvin_StopDecoder(); |
2140 | |
2141 | tvin_info_t info = mSigDetectThread.getCurSigInfo(); |
2142 | TvEvent::SignalInfoEvent ev; |
2143 | ev.mTrans_fmt = info.trans_fmt; |
2144 | ev.mFmt = info.fmt; |
2145 | ev.mStatus = info.status; |
2146 | ev.mReserved = info.reserved; |
2147 | sendTvEvent ( ev ); |
2148 | LOGD ( "%s, Enable bluescreen for signal change in StableToNoSig!", __FUNCTION__); |
2149 | } |
2150 | |
2151 | void CTv::onSigUnStableToUnSupport() |
2152 | { |
2153 | mAv.DisableVideoWithBlackColor(); |
2154 | mTvin.Tvin_StopDecoder(); |
2155 | tvin_info_t info = mSigDetectThread.getCurSigInfo(); |
2156 | |
2157 | TvEvent::SignalInfoEvent ev; |
2158 | ev.mTrans_fmt = info.trans_fmt; |
2159 | ev.mFmt = info.fmt; |
2160 | ev.mStatus = info.status; |
2161 | ev.mReserved = info.reserved; |
2162 | sendTvEvent ( ev ); |
2163 | LOGD ( "%s, Enable blackscreen for signal change in UnStableToUnSupport!", __FUNCTION__); |
2164 | } |
2165 | |
2166 | void CTv::onSigUnStableToNoSig() |
2167 | { |
2168 | SetAudioMuteForTv(CC_AUDIO_MUTE); |
2169 | const char *value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); |
2170 | if ( strcmp ( value, "black" ) == 0 ) { |
2171 | mAv.DisableVideoWithBlackColor(); |
2172 | } else { |
2173 | mAv.DisableVideoWithBlueColor(); |
2174 | //SetAudioMuteForTv(CC_AUDIO_MUTE); |
2175 | } |
2176 | mTvin.Tvin_StopDecoder(); |
2177 | |
2178 | tvin_info_t info = mSigDetectThread.getCurSigInfo(); |
2179 | TvEvent::SignalInfoEvent ev; |
2180 | ev.mTrans_fmt = info.trans_fmt; |
2181 | ev.mFmt = info.fmt; |
2182 | ev.mStatus = info.status; |
2183 | ev.mReserved = info.reserved; |
2184 | sendTvEvent ( ev ); |
2185 | LOGD ( "%s, Enable bluescreen for signal change in UnStableToNoSig! status = %d", __FUNCTION__, ev.mStatus ); |
2186 | } |
2187 | |
2188 | void CTv::onSigNullToNoSig() |
2189 | { |
2190 | SetAudioMuteForTv(CC_AUDIO_MUTE); |
2191 | const char *value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); |
2192 | if ( strcmp ( value, "black" ) == 0 ) { |
2193 | mAv.DisableVideoWithBlackColor(); |
2194 | } else { |
2195 | mAv.DisableVideoWithBlueColor(); |
2196 | //SetAudioMuteForTv(CC_AUDIO_MUTE); |
2197 | } |
2198 | mTvin.Tvin_StopDecoder(); |
2199 | |
2200 | tvin_info_t info = mSigDetectThread.getCurSigInfo(); |
2201 | |
2202 | TvEvent::SignalInfoEvent ev; |
2203 | ev.mTrans_fmt = info.trans_fmt; |
2204 | ev.mFmt = info.fmt; |
2205 | ev.mStatus = info.status; |
2206 | ev.mReserved = info.reserved; |
2207 | sendTvEvent ( ev ); |
2208 | LOGD ( "%s, Enable bluescreen for signal change in NullToNoSig!", __FUNCTION__); |
2209 | } |
2210 | |
2211 | void CTv::onSigNoSigToUnstable() |
2212 | { |
2213 | const char *value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); |
2214 | if ( strcmp ( value, "black" ) == 0 ) { |
2215 | mAv.DisableVideoWithBlackColor(); |
2216 | } else { |
2217 | mAv.DisableVideoWithBlueColor(); |
2218 | } |
2219 | LOGD("Enable bluescreen for signal change in NoSigToUnstable\n"); |
2220 | } |
2221 | |
2222 | void CTv::onSigStillUnstable() |
2223 | { |
2224 | } |
2225 | |
2226 | void CTv::onSigStillNosig() |
2227 | { |
2228 | } |
2229 | |
2230 | void CTv::onSigStillNoSupport() |
2231 | { |
2232 | return;//change for gxtvbb, don't send event when sitll not support |
2233 | /* |
2234 | tvin_info_t info = mSigDetectThread.getCurSigInfo(); |
2235 | TvEvent::SignalInfoEvent SigEv; |
2236 | SigEv.mTrans_fmt = info.trans_fmt; |
2237 | SigEv.mFmt = info.fmt; |
2238 | SigEv.mStatus = info.status; |
2239 | SigEv.mReserved = info.reserved; |
2240 | sendTvEvent ( SigEv ); |
2241 | LOGD ( "%s, Unsupport signal", __FUNCTION__); |
2242 | */ |
2243 | } |
2244 | |
2245 | void CTv::onSigStillNull() |
2246 | { |
2247 | } |
2248 | |
2249 | void CTv::onStableSigFmtChange() |
2250 | { |
2251 | if ( mAutoSetDisplayFreq) { |
2252 | if (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) { |
2253 | int fps = getHDMIFrameRate(); |
2254 | LOGD("onSigToStable HDMI fps get = %d", fps); |
2255 | } |
2256 | int freq = 60; |
2257 | if ( CTvin::Tvin_is50HzFrameRateFmt ( mSigDetectThread.getCurSigInfo().fmt ) ) { |
2258 | freq = 50; |
2259 | } |
2260 | |
2261 | mTvin.VDIN_SetDisplayVFreq ( freq, mAv.getVideoDisplayResolution(), mHdmiOutFbc ); |
2262 | LOGD ( "%s, SetDisplayVFreq %dHZ.", __FUNCTION__, freq); |
2263 | } |
2264 | //showbo mark hdmi auto 3d, tran fmt is 3d, so switch to 3d |
2265 | LOGD("hdmi trans_fmt = %d", mSigDetectThread.getCurSigInfo().trans_fmt); |
2266 | |
2267 | //load pq parameters |
2268 | mVpp.LoadVppSettings (CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt ); |
2269 | |
2270 | if ( m_win_mode == PREVIEW_WONDOW ) { |
2271 | mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2); |
2272 | mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_FULL_STRETCH ); |
2273 | } else { |
2274 | SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt); |
2275 | } |
2276 | } |
2277 | |
2278 | void CTv::onStableTransFmtChange() |
2279 | { |
2280 | LOGD("onStableTransFmtChange trans_fmt = %d", mSigDetectThread.getCurSigInfo().trans_fmt); |
2281 | } |
2282 | |
2283 | void CTv::onSigDetectEnter() |
2284 | { |
2285 | } |
2286 | |
2287 | void CTv::onSigDetectLoop() |
2288 | { |
2289 | if (( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) ) { |
2290 | int sr = mTvin.get_hdmi_sampling_rate(); |
2291 | if ( ( sr > 0 ) && ( sr != m_hdmi_sampling_rate ) ) { |
2292 | LOGD("HDMI SR CHANGED"); |
2293 | CMessage msg; |
2294 | msg.mDelayMs = 0; |
2295 | msg.mType = CTvMsgQueue::TV_MSG_HDMI_SR_CHANGED; |
2296 | ((int *)(msg.mpPara))[0] = sr; |
2297 | ((int *)(msg.mpPara))[1] = m_hdmi_sampling_rate; |
2298 | mTvMsgQueue.sendMsg ( msg ); |
2299 | m_hdmi_sampling_rate = sr; |
2300 | } |
2301 | |
2302 | //m_hdmi_audio_data init is 0, not audio data , when switch to HDMI |
2303 | int hdmi_audio_data = mTvin.TvinApi_GetHDMIAudioStatus(); |
2304 | if (hdmi_audio_data != m_hdmi_audio_data) { |
2305 | LOGD("HDMI auds_rcv_sts CHANGED = %d", hdmi_audio_data); |
2306 | m_hdmi_audio_data = hdmi_audio_data; |
2307 | onHMDIAudioStatusChanged(hdmi_audio_data); |
2308 | } |
2309 | } |
2310 | } |
2311 | |
2312 | CTv::CTvDetectObserverForScanner::CTvDetectObserverForScanner(CTv *pTv) |
2313 | { |
2314 | mpTv = pTv; |
2315 | m_sig_stable_nums = 0; |
2316 | } |
2317 | |
2318 | void CTv::CTvDetectObserverForScanner::onSigStableToUnstable() |
2319 | { |
2320 | LOGD ( "%s, stable to unstable\n", __FUNCTION__); |
2321 | mpTv->SetAudioMuteForTv(CC_AUDIO_MUTE); |
2322 | mpTv->SetAudioMuteForTv(CC_AUDIO_MUTE); |
2323 | const char *value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); |
2324 | if ( strcmp ( value, "black" ) == 0 ) { |
2325 | mpTv->mAv.DisableVideoWithBlackColor(); |
2326 | } else { |
2327 | mpTv->mAv.DisableVideoWithBlueColor(); |
2328 | } |
2329 | mpTv->mTvin.Tvin_StopDecoder(); |
2330 | } |
2331 | |
2332 | void CTv::CTvDetectObserverForScanner::onSigUnStableToNoSig() |
2333 | { |
2334 | mpTv->SetAudioMuteForTv(CC_AUDIO_MUTE); |
2335 | const char *value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); |
2336 | if ( strcmp ( value, "black" ) == 0 ) { |
2337 | mpTv->mAv.DisableVideoWithBlackColor(); |
2338 | } else { |
2339 | mpTv->mAv.DisableVideoWithBlueColor(); |
2340 | } |
2341 | mpTv->mTvin.Tvin_StopDecoder(); |
2342 | } |
2343 | |
2344 | void CTv::CTvDetectObserverForScanner::onSigStableToNoSig() |
2345 | { |
2346 | mpTv->SetAudioMuteForTv(CC_AUDIO_MUTE); |
2347 | const char *value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); |
2348 | if ( strcmp ( value, "black" ) == 0 ) { |
2349 | mpTv->mAv.DisableVideoWithBlackColor(); |
2350 | } else { |
2351 | mpTv->mAv.DisableVideoWithBlueColor(); |
2352 | } |
2353 | mpTv->mTvin.Tvin_StopDecoder(); |
2354 | LOGD ( "%s, Enable bluescreen for signal change in StableToNoSig!", __FUNCTION__); |
2355 | } |
2356 | |
2357 | void CTv::CTvDetectObserverForScanner::onSigToStable() |
2358 | { |
2359 | mpTv->mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_16_9 ); |
2360 | m_sig_stable_nums = 0; |
2361 | } |
2362 | |
2363 | void CTv::CTvDetectObserverForScanner::onSigStillStable() |
2364 | { |
2365 | if (m_sig_stable_nums == 1) { |
2366 | LOGD("%s still stable , to start decoder", __FUNCTION__); |
2367 | int startdec_status = mpTv->mTvin.Tvin_StartDecoder (mpTv->mSigDetectThread.getCurSigInfo() ); |
2368 | if ( startdec_status == 0 ) { |
2369 | const char *value = config_get_str ( CFG_SECTION_TV, "tvin.db.reg.en", "null" ); |
2370 | if ( strcmp ( value, "enable" ) == 0 ) { |
2371 | usleep ( 20 * 1000 ); |
2372 | mpTv->Tvin_SetPLLValues (); |
2373 | usleep ( 20 * 1000 ); |
2374 | mpTv->SetCVD2Values (); |
2375 | } |
2376 | } |
2377 | } |
2378 | if ( m_sig_stable_nums == 10 ) { |
2379 | mpTv->mAv.EnableVideoWhenVideoPlaying(); |
2380 | } |
2381 | m_sig_stable_nums++; |
2382 | } |
2383 | |
2384 | void CTv::onSourceConnect(int source_type, int connect_status) |
2385 | { |
2386 | TvEvent::SourceConnectEvent ev; |
2387 | ev.mSourceInput = source_type; |
2388 | ev.connectionState = connect_status; |
2389 | sendTvEvent(ev); |
2390 | } |
2391 | |
2392 | void CTv::onVframeSizeChange() |
2393 | { |
2394 | if (m_source_input == SOURCE_DTV) { |
2395 | mVpp.LoadVppSettings ( SOURCE_TYPE_DTV, mAv.getVideoResolutionToFmt(), INDEX_2D, TVIN_TFMT_2D ); |
2396 | } else if (m_source_input == SOURCE_INVALID) { |
2397 | mVpp.LoadVppSettings ( SOURCE_TYPE_MPEG, mAv.getVideoResolutionToFmt(), INDEX_2D, TVIN_TFMT_2D ); |
2398 | } |
2399 | } |
2400 | |
2401 | int CTv::GetSourceConnectStatus(tv_source_input_t source_input) |
2402 | { |
2403 | return mSourceConnectDetectThread.GetSourceConnectStatus((tv_source_input_t)source_input); |
2404 | } |
2405 | |
2406 | tv_source_input_t CTv::GetCurrentSourceInputLock ( void ) |
2407 | { |
2408 | Mutex::Autolock _l ( mLock ); |
2409 | return m_source_input; |
2410 | } |
2411 | |
2412 | //dtv and tvin |
2413 | tvin_info_t CTv::GetCurrentSignalInfo ( void ) |
2414 | { |
2415 | tvin_trans_fmt det_fmt = TVIN_TFMT_2D; |
2416 | tvin_sig_status_t signalState = TVIN_SIG_STATUS_NULL; |
2417 | tvin_info_t signal_info = mSigDetectThread.getCurSigInfo(); |
2418 | |
2419 | int feState = mFrontDev.getStatus(); |
2420 | if ( (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_DTV ) ) { |
2421 | det_fmt = mTvin.TvinApi_Get3DDectMode(); |
2422 | if ((feState & FE_HAS_LOCK) == FE_HAS_LOCK) { |
2423 | signal_info.status = TVIN_SIG_STATUS_STABLE; |
2424 | } else if ((feState & FE_TIMEDOUT) == FE_TIMEDOUT) { |
2425 | signal_info.status = TVIN_SIG_STATUS_NOSIG; |
2426 | } |
2427 | if ( det_fmt != TVIN_TFMT_2D ) { |
2428 | signal_info.trans_fmt = det_fmt; |
2429 | } |
2430 | signal_info.fmt = mAv.getVideoResolutionToFmt(); |
2431 | } |
2432 | return signal_info; |
2433 | } |
2434 | |
2435 | int CTv::Tv_GetHistgram(int *histgram_buf) |
2436 | { |
2437 | if (histgram_buf == NULL) { |
2438 | return -1; |
2439 | } |
2440 | return mTvin.VDIN_GetHistgram(histgram_buf); |
2441 | } |
2442 | |
2443 | int CTv::Tv_Set3DMode ( VIDEO_3D_MODE_T mode ) |
2444 | { |
2445 | if (mode == VIDEO_3D_MODE_AUTO) { |
2446 | mTvin.VDIN_SetDI3DDetc (1); |
2447 | } else { |
2448 | mTvin.VDIN_SetDI3DDetc (0); |
2449 | } |
2450 | |
2451 | mAv.set3DMode(mode, 0, 0); |
2452 | m_mode_3d = mode; |
2453 | SSMSave3DMode ( ( unsigned char ) mode ); |
2454 | return 0; |
2455 | } |
2456 | |
2457 | VIDEO_3D_MODE_T CTv::Tv_Get3DMode ( void ) |
2458 | { |
2459 | return m_mode_3d; |
2460 | } |
2461 | |
2462 | int CTv::Tv_Set3DLRSwith ( int on_off) |
2463 | { |
2464 | LOGW ( "%s,Set3D LRSwith on_off %d ,status %d !!! ", __FUNCTION__, on_off); |
2465 | mAv.set3DMode(m_mode_3d, on_off, 0); |
2466 | SSMSave3DLRSwitch(on_off); |
2467 | return 0; |
2468 | } |
2469 | |
2470 | int CTv::Tv_Get3DLRSwith ( void ) |
2471 | { |
2472 | unsigned char val = 0; |
2473 | SSMRead3DLRSwitch ( &val ); |
2474 | return ( int ) val; |
2475 | } |
2476 | |
2477 | int CTv::Tv_Set3DTo2DMode ( int mode) |
2478 | { |
2479 | LOGW ( "%s,Set3D to 2D mode %d ,status %d !!! ", __FUNCTION__ , mode); |
2480 | mAv.set3DMode(m_mode_3d, 0, mode); |
2481 | SSMSave3DTO2D ( mode ); |
2482 | return 0; |
2483 | } |
2484 | |
2485 | int CTv::Tv_Get3DTo2DMode ( void ) |
2486 | { |
2487 | unsigned char val = 0; |
2488 | SSMRead3DTO2D ( &val ); |
2489 | return val; |
2490 | } |
2491 | |
2492 | int CTv::Tv_Set3DDepth ( int value ) |
2493 | { |
2494 | mTvin.Tvin_SetDepthOf2Dto3D( value ); |
2495 | SSMSave3DDepth ( value ); |
2496 | return 0; |
2497 | } |
2498 | |
2499 | int CTv::GetSave3DDepth ( void ) |
2500 | { |
2501 | unsigned char val = 0; |
2502 | SSMRead3DDepth ( &val ); |
2503 | return val; |
2504 | } |
2505 | |
2506 | is_3d_type_t CTv::Check2Dor3D ( VIDEO_3D_MODE_T mode3d, tvin_trans_fmt_t trans_fmt ) |
2507 | { |
2508 | if ( mode3d == VIDEO_3D_MODE_DISABLE ) { |
2509 | return INDEX_2D; |
2510 | } else if ( mode3d == VIDEO_3D_MODE_AUTO ) { |
2511 | if ( trans_fmt == TVIN_TFMT_2D ) { |
2512 | return INDEX_2D; |
2513 | } else { |
2514 | return INDEX_3D; |
2515 | } |
2516 | } else { |
2517 | return INDEX_3D; |
2518 | } |
2519 | } |
2520 | |
2521 | int CTv::Tvin_SetPLLValues () |
2522 | { |
2523 | tvin_sig_fmt_t sig_fmt = mSigDetectThread.getCurSigInfo().fmt; |
2524 | tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceInput(m_source_input); |
2525 | am_regs_t regs; |
2526 | |
2527 | if ( mVpp.getPqData()->PQ_GetPLLParams ( source_port, sig_fmt, ®s ) == 0 ) { |
2528 | LOGD ("%s,PQ_GetPLLParams(source_port[%d], sig_fmt[%d],®s).\n", __FUNCTION__, source_port, sig_fmt ); |
2529 | |
2530 | if ( mTvin.TvinApi_LoadPLLValues ( regs ) < 0 ) { |
2531 | LOGE ( "%s, TvinApi_LoadPLLValues failed!\n", __FUNCTION__ ); |
2532 | return -1; |
2533 | } |
2534 | } else { |
2535 | LOGE ( "%s, PQ_GetPLLParams failed!\n", __FUNCTION__ ); |
2536 | return -1; |
2537 | } |
2538 | |
2539 | return 0; |
2540 | } |
2541 | |
2542 | int CTv::SetCVD2Values () |
2543 | { |
2544 | tvin_sig_fmt_t sig_fmt = mSigDetectThread.getCurSigInfo().fmt; |
2545 | tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceInput(m_source_input); |
2546 | am_regs_t regs; |
2547 | |
2548 | if (mVpp.getPqData()->PQ_GetCVD2Params ( source_port, sig_fmt, ®s ) == 0) { |
2549 | LOGD ( "%s, PQ_GetCVD2Params(source_port[%d], sig_fmt[%d],®s).\n", __FUNCTION__, |
2550 | source_port, sig_fmt ); |
2551 | |
2552 | if ( mTvin.TvinApi_LoadCVD2Values ( regs ) < 0 ) { |
2553 | LOGE ( "%s, TvinApi_LoadCVD2Values failed!\n", __FUNCTION__); |
2554 | return -1; |
2555 | } |
2556 | } else { |
2557 | LOGE ( "%s, PQ_GetCVD2Params failed!\n", __FUNCTION__); |
2558 | return -1; |
2559 | } |
2560 | |
2561 | return 0; |
2562 | } |
2563 | |
2564 | int CTv::SetPreviewWindow ( tvin_window_pos_t pos ) |
2565 | { |
2566 | m_win_pos.x1 = pos.x1; |
2567 | m_win_pos.y1 = pos.y1; |
2568 | m_win_pos.x2 = pos.x2; |
2569 | m_win_pos.y2 = pos.y2; |
2570 | LOGD ( "%s, SetPreviewWindow x = %d y=%d", __FUNCTION__, pos.x2, pos.y2 ); |
2571 | |
2572 | tvin_window_pos_t def_pos; |
2573 | Vpp_GetDisplayResolutionInfo(&def_pos); |
2574 | |
2575 | if (pos.x1 != 0 || pos.y1 != 0 || pos.x2 != def_pos.x2 || pos.y2 != def_pos.y2) { |
2576 | m_win_mode = PREVIEW_WONDOW; |
2577 | } else { |
2578 | m_win_mode = NORMAL_WONDOW; |
2579 | } |
2580 | |
2581 | return mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2); |
2582 | } |
2583 | |
2584 | /*********************** Audio start **********************/ |
2585 | int CTv::SetAudioVolDigitLUTTable ( tv_source_input_t source_input ) |
2586 | { |
2587 | int tmpDefDigitLutBuf[CC_LUT_BUF_SIZE] = { 0 }; |
2588 | int lut_table_index = 0; |
2589 | if (source_input == SOURCE_TV) { |
2590 | lut_table_index = CC_GET_LUT_TV; |
2591 | } else if (source_input == SOURCE_AV1 || source_input == SOURCE_AV2) { |
2592 | lut_table_index = CC_GET_LUT_AV; |
2593 | } else if (source_input == SOURCE_YPBPR1 || source_input == SOURCE_YPBPR2) { |
2594 | lut_table_index = CC_GET_LUT_COMP; |
2595 | } else if (source_input == SOURCE_VGA) { |
2596 | lut_table_index = CC_GET_LUT_VGA; |
2597 | } else if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) { |
2598 | lut_table_index = CC_GET_LUT_HDMI; |
2599 | } else if ( source_input == SOURCE_MPEG ) { |
2600 | lut_table_index = CC_GET_LUT_MPEG; |
2601 | } else if ( source_input == SOURCE_DTV ) { |
2602 | lut_table_index = CC_GET_LUT_MPEG; |
2603 | } else if ( source_input == SOURCE_MAX) { |
2604 | return 0; |
2605 | } |
2606 | char MainVolLutTableName[128]; |
2607 | const char *baseName = GetAudioAmpMainvolTableBaseName(lut_table_index); |
2608 | strcpy(MainVolLutTableName, baseName); |
2609 | const char *dName = "."; |
2610 | strcat(MainVolLutTableName, dName); |
2611 | strcat(MainVolLutTableName, GetMainVolLutTableExtraName()); |
2612 | if ( GetAudioAmpMainvolBuf(MainVolLutTableName, tmpDefDigitLutBuf) == 0) { |
2613 | AudioSetVolumeDigitLUTBuf ( lut_table_index, tmpDefDigitLutBuf); |
2614 | } |
2615 | return 0; |
2616 | } |
2617 | |
2618 | void CTv::RefreshAudioMasterVolume ( tv_source_input_t source_input ) |
2619 | { |
2620 | if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) { |
2621 | if ( GetAudioDVISupportEnable() == 1 ) { |
2622 | if ( IsDVISignal() ) { |
2623 | SetAudioVolDigitLUTTable ( SOURCE_MPEG ); |
2624 | SetAudioMasterVolume ( GetAudioMasterVolume() ); |
2625 | return; |
2626 | } |
2627 | } |
2628 | } |
2629 | |
2630 | SetAudioVolDigitLUTTable ( source_input ); |
2631 | SetAudioMasterVolume ( GetAudioMasterVolume() ); |
2632 | } |
2633 | |
2634 | int CTv::Tv_SetAudioInSource (tv_source_input_t source_input) |
2635 | { |
2636 | int vol = 255; |
2637 | if (source_input == SOURCE_TV) { |
2638 | if (mTvin.Tvin_GetAudioInSourceType(source_input) == TV_AUDIO_IN_SOURCE_TYPE_ATV) { |
2639 | AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_ATV); |
2640 | vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_ATV); |
2641 | LOGD("%s, atv DAC_Digital_PlayBack_Volume = %d\n", __FUNCTION__, vol); |
2642 | } else { |
2643 | LOGD("%s, dtv DAC_Digital_PlayBack_Volume = %d\n", __FUNCTION__, vol); |
2644 | AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_LINEIN); |
2645 | vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_LINEIN); |
2646 | } |
2647 | } else if (source_input == SOURCE_AV1 || source_input == SOURCE_AV2) { |
2648 | AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_LINEIN); |
2649 | vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_LINEIN); |
2650 | } else if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) { |
2651 | AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_HDMI); |
2652 | vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_HDMI); |
2653 | } else if (source_input == SOURCE_YPBPR1 || source_input == SOURCE_YPBPR2 || |
2654 | source_input == SOURCE_TYPE_VGA) { |
2655 | AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_LINEIN); |
2656 | vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_LINEIN); |
2657 | } else if (source_input == SOURCE_MPEG) { |
2658 | AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_HDMI); |
2659 | vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_HDMI); |
2660 | } else if (source_input == SOURCE_DTV) { |
2661 | AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_HDMI); |
2662 | vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_HDMI); |
2663 | LOGD("%s, dtv DAC_Digital_PlayBack_Volume = %d\n", __FUNCTION__, vol); |
2664 | } |
2665 | LOGD("%s, we have read SetDAC_Digital_PlayBack_Volume = %d\n", __FUNCTION__, vol); |
2666 | |
2667 | return 0; |
2668 | } |
2669 | |
2670 | int CTv::Tv_SetAudioSourceType (tv_source_input_t source_input) |
2671 | { |
2672 | int audio_source = -1; |
2673 | |
2674 | if (source_input == SOURCE_TV) { |
2675 | audio_source = AUDIO_ATV_SOURCE; |
2676 | } else if (source_input == SOURCE_AV1 || source_input == SOURCE_AV2) { |
2677 | audio_source = AUDIO_AV_SOURCE; |
2678 | } else if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || |
2679 | source_input == SOURCE_HDMI3) { |
2680 | audio_source = AUDIO_HDMI_SOURCE; |
2681 | } else if (source_input == SOURCE_YPBPR1 || source_input == SOURCE_YPBPR2 || |
2682 | source_input == SOURCE_TYPE_VGA) { |
2683 | audio_source = AUDIO_AV_SOURCE; |
2684 | } else if (source_input == SOURCE_DTV) { |
2685 | audio_source = AUDIO_MPEG_SOURCE; |
2686 | } else { |
2687 | audio_source = AUDIO_MPEG_SOURCE; |
2688 | } |
2689 | |
2690 | return AudioSetAudioSourceType(audio_source); |
2691 | } |
2692 | |
2693 | void CTv::Tv_SetAudioOutputSwap_Type (tv_source_input_t source_input) |
2694 | { |
2695 | int sw_status = GetAudioOutputSwapStatus(source_input); |
2696 | SetOutput_Swap(sw_status); |
2697 | } |
2698 | |
2699 | void CTv::Tv_ADCDigitalCapture_Volume (void) |
2700 | { |
2701 | int capture_vol = GetADCDigitalCaptureVol_Cfg(); |
2702 | LOGD("%s, we have read ADCDigitalCaptureVol_Config = %d \n", __FUNCTION__, capture_vol); |
2703 | SetADC_Digital_Capture_Volume(capture_vol); |
2704 | } |
2705 | |
2706 | void CTv::Tv_SetPGAIn_Gain (void) |
2707 | { |
2708 | int gain_val = GetAudioInternalDacPGAInGain_Cfg(); |
2709 | LOGD("%s, we have read ADCDigitalCaptureVol_Config = %d \n", __FUNCTION__, gain_val); |
2710 | SetPGA_IN_Value(gain_val); |
2711 | } |
2712 | |
2713 | void CTv::Tv_SetDACDigitalPlayBack_Volume (int audio_src_in_type) |
2714 | { |
2715 | int vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(audio_src_in_type); |
2716 | LOGD("%s, we have read DACDigitalPlayBackVolume config = %d \n", __FUNCTION__, vol); |
2717 | SetDAC_Digital_PlayBack_Volume(vol); |
2718 | } |
2719 | /*********************** Audio end **********************/ |
2720 | |
2721 | unsigned int CTv::Vpp_GetDisplayResolutionInfo(tvin_window_pos_t *win_pos) |
2722 | { |
2723 | int display_resolution = mAv.getVideoDisplayResolution(); |
2724 | int width = 0, height = 0; |
2725 | switch (display_resolution) { |
2726 | case VPP_DISPLAY_RESOLUTION_1366X768: |
2727 | width = CC_RESOLUTION_1366X768_W; |
2728 | height = CC_RESOLUTION_1366X768_H; |
2729 | break; |
2730 | case VPP_DISPLAY_RESOLUTION_1920X1080: |
2731 | width = CC_RESOLUTION_1920X1080_W; |
2732 | height = CC_RESOLUTION_1920X1080_H; |
2733 | break; |
2734 | case VPP_DISPLAY_RESOLUTION_3840X2160: |
2735 | width = CC_RESOLUTION_3840X2160_W; |
2736 | height = CC_RESOLUTION_3840X2160_H; |
2737 | break; |
2738 | default: |
2739 | width = CC_RESOLUTION_3840X2160_W; |
2740 | height = CC_RESOLUTION_3840X2160_H; |
2741 | break; |
2742 | } |
2743 | |
2744 | if (win_pos != NULL) { |
2745 | win_pos->x1 = 0; |
2746 | win_pos->y1 = 0; |
2747 | win_pos->x2 = width - 1; |
2748 | win_pos->y2 = height - 1; |
2749 | } |
2750 | return 0; |
2751 | } |
2752 | |
2753 | int CTv::setBlackoutEnable(int enable) |
2754 | { |
2755 | m_blackout_enable = enable; |
2756 | return SSMSaveBlackoutEnable(enable); |
2757 | } |
2758 | |
2759 | int CTv::getSaveBlackoutEnable() |
2760 | { |
2761 | int8_t enable; |
2762 | SSMReadBlackoutEnable(&enable); |
2763 | return enable; |
2764 | } |
2765 | |
2766 | void CTv::startAutoBackLight() |
2767 | { |
2768 | if (mHdmiOutFbc) { |
2769 | Tv_FactorySet_FBC_Auto_Backlight_OnOff(1); |
2770 | } else { |
2771 | mAutoBackLight.startAutoBacklight(CTvin::Tvin_SourceInputToSourceInputType(m_source_input)); |
2772 | } |
2773 | } |
2774 | |
2775 | void CTv::stopAutoBackLight() |
2776 | { |
2777 | if (mHdmiOutFbc) { |
2778 | Tv_FactorySet_FBC_Auto_Backlight_OnOff(0); |
2779 | } else { |
2780 | mAutoBackLight.stopAutoBacklight(); |
2781 | } |
2782 | } |
2783 | |
2784 | int CTv::getAutoBackLight_on_off() |
2785 | { |
2786 | if (mHdmiOutFbc) { |
2787 | return Tv_FactoryGet_FBC_Auto_Backlight_OnOff(); |
2788 | } else { |
2789 | return mAutoBackLight.isAutoBacklightOn() ? 1 : 0; |
2790 | } |
2791 | } |
2792 | |
2793 | int CTv::getAverageLuma() |
2794 | { |
2795 | return mTvin.VDIN_Get_avg_luma(); |
2796 | } |
2797 | |
2798 | int CTv::setAutobacklightData(const char *value) |
2799 | { |
2800 | const char *KEY = "haier.autobacklight.mp.data"; |
2801 | |
2802 | const char *keyValue = config_get_str(CFG_SECTION_TV, KEY, "null"); |
2803 | if (strcmp(keyValue, value) != 0) { |
2804 | config_set_str(CFG_SECTION_TV, KEY, value); |
2805 | LOGD("%s, config string now set as: %s \n", __FUNCTION__, keyValue); |
2806 | } else { |
2807 | LOGD("%s, config string has been set as: %s \n", __FUNCTION__, keyValue); |
2808 | } |
2809 | return 0; |
2810 | } |
2811 | |
2812 | int CTv::getAutoBacklightData(int *data) |
2813 | { |
2814 | char datas[512] = {0}; |
2815 | char delims[] = ","; |
2816 | char *result = NULL; |
2817 | const char *KEY = "haier.autobacklight.mp.data"; |
2818 | int i = 0; |
2819 | |
2820 | if (NULL == data) { |
2821 | LOGD("%s, data is null", __FUNCTION__); |
2822 | return -1; |
2823 | } |
2824 | |
2825 | const char *keyValue = config_get_str(CFG_SECTION_TV, KEY, (char *) "null"); |
2826 | if (strcmp(keyValue, "null") == 0) { |
2827 | LOGD("%s, value is NULL\n", __FUNCTION__); |
2828 | return -1; |
2829 | } |
2830 | |
2831 | strncpy(datas, keyValue, sizeof(datas) - 1); |
2832 | result = strtok( datas, delims ); |
2833 | while ( result != NULL ) { |
2834 | char *pd = strstr(result, ":"); |
2835 | if (pd != NULL) { |
2836 | data[i] = strtol(pd + 1, NULL, 10 ); |
2837 | i++; |
2838 | } |
2839 | result = strtok( NULL, delims ); |
2840 | } |
2841 | return i; |
2842 | } |
2843 | |
2844 | /*********************** SSM start **********************/ |
2845 | int CTv::Tv_SSMRestoreDefaultSetting() |
2846 | { |
2847 | SSMRestoreDeviceMarkValues(); |
2848 | AudioSSMRestoreDefaultSetting(); |
2849 | mVpp.VPPSSMRestoreDefault(); |
2850 | MiscSSMRestoreDefault(); |
2851 | ReservedSSMRestoreDefault(); |
2852 | SSMSaveCVBSStd ( 0 ); |
2853 | SSMSaveLastSelectSourceInput ( SOURCE_TV ); |
2854 | SSMSavePanelType ( 0 ); |
2855 | //tvconfig default |
2856 | saveDTVProgramID ( -1 ); |
2857 | saveATVProgramID ( -1 ); |
2858 | SSMSaveStandbyMode( 0 ); |
2859 | return 0; |
2860 | } |
2861 | |
2862 | int CTv::clearDbAllProgramInfoTable() |
2863 | { |
2864 | return CTvDatabase::GetTvDb()->clearDbAllProgramInfoTable(); |
2865 | } |
2866 | |
2867 | int CTv::Tv_SSMFacRestoreDefaultSetting() |
2868 | { |
2869 | mVpp.VPPSSMFacRestoreDefault(); |
2870 | AudioSSMRestoreDefaultSetting(); |
2871 | MiscSSMFacRestoreDefault(); |
2872 | return 0; |
2873 | } |
2874 | /*********************** SSM End **********************/ |
2875 | |
2876 | //not in CTv, not use lock |
2877 | void CTv::setSourceSwitchAndPlay() |
2878 | { |
2879 | int progID = 0; |
2880 | CTvProgram prog; |
2881 | LOGD ( "%s\n", __FUNCTION__ ); |
2882 | static const int POWERON_SOURCE_TYPE_NONE = 0;//not play source |
2883 | static const int POWERON_SOURCE_TYPE_LAST = 1;//play last save source |
2884 | static const int POWERON_SOURCE_TYPE_SETTING = 2;//play ui set source |
2885 | int to_play_source = -1; |
2886 | int powerup_type = SSMReadPowerOnOffChannel(); |
2887 | LOGD("read power on source type = %d", powerup_type); |
2888 | if (powerup_type == POWERON_SOURCE_TYPE_NONE) { |
2889 | return ; |
2890 | } else if (powerup_type == POWERON_SOURCE_TYPE_LAST) { |
2891 | to_play_source = SSMReadSourceInput(); |
2892 | } else if (powerup_type == POWERON_SOURCE_TYPE_SETTING) { |
2893 | to_play_source = SSMReadLastSelectSourceInput(); |
2894 | } |
2895 | SetSourceSwitchInput (( tv_source_input_t ) to_play_source ); |
2896 | if ( to_play_source == SOURCE_TV ) { |
2897 | progID = getATVProgramID(); |
2898 | } else if ( to_play_source == SOURCE_DTV ) { |
2899 | progID = getDTVProgramID(); |
2900 | } |
2901 | playProgramLock(progID); |
2902 | } |
2903 | |
2904 | int CTv::startCC(int country, int src, int channel, int service) |
2905 | { |
2906 | //turn_on_cc = true; |
2907 | return mSubtitle.sub_start_atsc_cc((enum cc_param_country)country, (enum cc_param_source_type)src, channel, (enum cc_param_caption_type)service); |
2908 | } |
2909 | |
2910 | int CTv::stopCC() |
2911 | { |
2912 | //because cc,vchip data both come from vbi thread , here judge cc, vchip is whether both turn off |
2913 | /*turn_on_cc = false; |
2914 | if (config_get_int(CFG_SECTION_TV,"tv.vchip.enable", 0)) |
2915 | { |
2916 | return 0; //at ATV if vchip is on, turn off CC, just set flag not display CC, but vchip still running |
2917 | }*/ |
2918 | return mSubtitle.sub_stop_atsc_cc(); |
2919 | } |
2920 | |
2921 | void CTv::printDebugInfo() |
2922 | { |
2923 | print_version_info(); |
2924 | LOGD("%s, TvAction = %x", __FUNCTION__, mTvAction); |
2925 | LOGD("%s, TvRunStatus = %d", __FUNCTION__, mTvStatus); |
2926 | LOGD("%s, TvCurSourceInput = %d", __FUNCTION__, m_source_input); |
2927 | LOGD("%s, TvLastSourceInput = %d", __FUNCTION__, m_last_source_input); |
2928 | } |
2929 | //==============vchip end================================ |
2930 | |
2931 | //----------------DVR API============================ |
2932 | void CTv::SetRecordFileName ( char *name ) |
2933 | { |
2934 | mTvRec.SetRecordFileName (name); |
2935 | } |
2936 | |
2937 | void CTv::StartToRecord() |
2938 | { |
2939 | int progID = getDTVProgramID(); |
2940 | mTvRec.StartRecord ( progID ); |
2941 | } |
2942 | |
2943 | void CTv::StopRecording() |
2944 | { |
2945 | mTvRec.StopRecord(); |
2946 | } |
2947 | |
2948 | void CTv::SetRecCurTsOrCurProgram ( int sel ) |
2949 | { |
2950 | mTvRec.SetRecCurTsOrCurProgram ( sel ); |
2951 | } |
2952 | |
2953 | int CTv::GetDisplayResolutionConfig() |
2954 | { |
2955 | return mAv.getVideoDisplayResolution(); |
2956 | } |
2957 | |
2958 | int CTv::GetDisplayResolutionInfo() |
2959 | { |
2960 | return Vpp_GetDisplayResolutionInfo(NULL); |
2961 | } |
2962 | |
2963 | void CTv::onHDMIRxCECMessage(int msg_len, unsigned char msg_buf[]) |
2964 | { |
2965 | TvEvent::HDMIRxCECEvent ev; |
2966 | |
2967 | int bufLen = sizeof(ev.mDataBuf) / sizeof(ev.mDataBuf[0]); |
2968 | if (msg_len > bufLen) { |
2969 | LOGE("%s, message len(%d) > buffer len(%d)", __FUNCTION__, msg_len, bufLen); |
2970 | return; |
2971 | } |
2972 | |
2973 | ev.mDataCount = msg_len; |
2974 | for (int i = 0; i < msg_len; i++) { |
2975 | ev.mDataBuf[i] = msg_buf[i]; |
2976 | } |
2977 | sendTvEvent(ev); |
2978 | } |
2979 | |
2980 | int CTv::SendHDMIRxCECCustomMessage(unsigned char data_buf[]) |
2981 | { |
2982 | return mHDMIRxCEC.SendCustomMessage(m_source_input, data_buf); |
2983 | } |
2984 | |
2985 | int CTv::SendHDMIRxCECCustomMessageAndWaitReply(unsigned char data_buf[], unsigned char reply_buf[], int WaitCmd, int timeout) |
2986 | { |
2987 | return mHDMIRxCEC.SendCustomMessageAndWaitReply(m_source_input, data_buf, reply_buf, WaitCmd, timeout); |
2988 | } |
2989 | |
2990 | int CTv::SendHDMIRxCECBoradcastStandbyMessage(void) |
2991 | { |
2992 | return mHDMIRxCEC.SendBoradcastStandbyMessage(m_source_input); |
2993 | } |
2994 | |
2995 | int CTv::SendHDMIRxCECGiveCECVersionMessage(tv_source_input_t source_input, unsigned char data_buf[]) |
2996 | { |
2997 | if (mHDMIRxCEC.processRefreshSrcDevice(source_input) == 0) { |
2998 | return mHDMIRxCEC.SendGiveCECVersionMessage(source_input, data_buf); |
2999 | } |
3000 | |
3001 | return -1; |
3002 | } |
3003 | |
3004 | int CTv::SendHDMIRxCECGiveDeviceVendorIDMessage(tv_source_input_t source_input, unsigned char data_buf[]) |
3005 | { |
3006 | if (mHDMIRxCEC.processRefreshSrcDevice(source_input) == 0) { |
3007 | return mHDMIRxCEC.SendGiveDeviceVendorIDMessage(source_input, data_buf); |
3008 | } |
3009 | |
3010 | return -1; |
3011 | } |
3012 | |
3013 | int CTv::SendHDMIRxCECGiveOSDNameMessage(tv_source_input_t source_input, unsigned char data_buf[]) |
3014 | { |
3015 | if (mHDMIRxCEC.processRefreshSrcDevice(source_input) == 0) { |
3016 | return mHDMIRxCEC.SendGiveOSDNameMessage(source_input, data_buf); |
3017 | } |
3018 | |
3019 | return -1; |
3020 | } |
3021 | |
3022 | int CTv::GetHdmiHdcpKeyKsvInfo(int data_buf[]) |
3023 | { |
3024 | return mTvin.get_hdmi_ksv_info(m_source_input, data_buf); |
3025 | } |
3026 | |
3027 | bool CTv::hdmiOutWithFbc() |
3028 | { |
3029 | const char *value = config_get_str(CFG_SECTION_TV, "platform.havefbc", "true"); |
3030 | if (strcmp(value, "true") == 0) { |
3031 | return true; |
3032 | } |
3033 | |
3034 | return false; |
3035 | } |
3036 | |
3037 | void CTv::onUpgradeStatus(int state, int param) |
3038 | { |
3039 | TvEvent::UpgradeFBCEvent ev; |
3040 | ev.mState = state; |
3041 | ev.param = param; |
3042 | sendTvEvent(ev); |
3043 | } |
3044 | |
3045 | int CTv::StartUpgradeFBC(char *file_name, int mode, int upgrade_blk_size) |
3046 | { |
3047 | if (mpUpgradeFBC != NULL) { |
3048 | mpUpgradeFBC->SetUpgradeFileName(file_name); |
3049 | mpUpgradeFBC->SetUpgradeMode(mode); |
3050 | mpUpgradeFBC->SetUpgradeBlockSize(upgrade_blk_size); |
3051 | mpUpgradeFBC->start(); |
3052 | return 0; |
3053 | } |
3054 | |
3055 | return -1; |
3056 | } |
3057 | |
3058 | void CTv::onSerialCommunication(int dev_id, int rd_len, unsigned char data_buf[]) |
3059 | { |
3060 | TvEvent::SerialCommunicationEvent ev; |
3061 | |
3062 | if (rd_len > CC_MAX_SERIAL_RD_BUF_LEN) { |
3063 | LOGE("%s, rd_len(%d) > buffer len(%d)", __FUNCTION__, rd_len, CC_MAX_SERIAL_RD_BUF_LEN); |
3064 | return; |
3065 | } |
3066 | |
3067 | ev.mDevId = dev_id; |
3068 | ev.mDataCount = rd_len; |
3069 | for (int i = 0; i < rd_len; i++) { |
3070 | ev.mDataBuf[i] = data_buf[i]; |
3071 | } |
3072 | sendTvEvent(ev); |
3073 | } |
3074 | |
3075 | int CTv::StartHeadSetDetect() |
3076 | { |
3077 | mHeadSet.startDetect(); |
3078 | return 0; |
3079 | } |
3080 | |
3081 | void CTv::onHeadSetDetect(int state, int para) |
3082 | { |
3083 | TvEvent::HeadSetOf2d4GEvent ev; |
3084 | if (state == 1) |
3085 | property_set("audio.headset_plug.enable", "1"); |
3086 | else |
3087 | property_set("audio.headset_plug.enable", "0"); |
3088 | ev.state = state; |
3089 | ev.para = para; |
3090 | sendTvEvent(ev); |
3091 | } |
3092 | |
3093 | void CTv::onThermalDetect(int state) |
3094 | { |
3095 | const char *value; |
3096 | const char *value_normal; |
3097 | const char *value_cold; |
3098 | int threshold = 0, val = 0; |
3099 | static int pre_val = -1; |
3100 | |
3101 | value = config_get_str ( CFG_SECTION_TV, "tvin.thermal.threshold.enable", "null" ); |
3102 | if ( strcmp ( value, "enable" ) == 0 ) { |
3103 | value = config_get_str ( CFG_SECTION_TV, "tvin.thermal.threshold.value", "null" ); |
3104 | threshold = atoi(value); |
3105 | LOGD ( "%s, threshold value: %d\n", __FUNCTION__, threshold); |
3106 | |
3107 | if (state > threshold) { |
3108 | value_normal = config_get_str ( CFG_SECTION_TV, "tvin.thermal.fbc.normal.value", "null" ); |
3109 | val = atoi(value_normal); |
3110 | if (val == 0) { |
3111 | val = 0x4210000; //normal default |
3112 | } |
3113 | LOGD ( "%s, current temp: %d set 1\n", __FUNCTION__, state); |
3114 | } else { |
3115 | value_cold = config_get_str ( CFG_SECTION_TV, "tvin.thermal.fbc.cold.value", "null" ); |
3116 | val = atoi(value_cold); |
3117 | if (val == 0) { |
3118 | val = 0x8210000; //cold default |
3119 | } |
3120 | LOGD ( "%s, current temp: 0x%x set 0\n", __FUNCTION__, state); |
3121 | } |
3122 | |
3123 | if (pre_val == val) { |
3124 | LOGD ( "%s, pre_val == val : 0x%x,bypass\n", __FUNCTION__, val); |
3125 | } else { |
3126 | pre_val = val; |
3127 | Tv_FactorySet_FBC_Thermal_State(val); |
3128 | LOGD ( "%s, pre_val :0x%x,bypass\n", __FUNCTION__, pre_val); |
3129 | } |
3130 | } else { |
3131 | LOGD ( "%s, tvin.thermal.threshold.enable == disable\n", __FUNCTION__); |
3132 | } |
3133 | } |
3134 | |
3135 | int CTv::SetDebugSerialOnOff(int on_off) |
3136 | { |
3137 | if (on_off) { |
3138 | property_set("ubootenv.var.console", "ttyS0,115200n8"); |
3139 | } else { |
3140 | property_set("ubootenv.var.console", "off"); |
3141 | } |
3142 | return 0; |
3143 | } |
3144 | |
3145 | int CTv::GetDebugSerialOnOff() |
3146 | { |
3147 | char prop[256] = {0}; |
3148 | property_get("ubootenv.var.console", prop, "null" ); |
3149 | if (!strcmp(prop, "ttyS0,115200n8")) { |
3150 | return 1; |
3151 | } else { |
3152 | return 0; |
3153 | } |
3154 | } |
3155 | |
3156 | int CTv::SetSerialSwitch(int dev_id, int switch_val) |
3157 | { |
3158 | int tmp_ret = 0; |
3159 | if (dev_id == SERIAL_A) { |
3160 | if (switch_val == 0) { |
3161 | tmp_ret |= mSerialA.stop(); |
3162 | tmp_ret |= mSerialA.CloseModule(); |
3163 | |
3164 | tmp_ret |= system("start console"); |
3165 | tmp_ret |= system("echo 7 > /proc/sys/kernel/printk"); |
3166 | } else { |
3167 | tmp_ret |= system("echo 0 > /proc/sys/kernel/printk"); |
3168 | tmp_ret |= system("stop console"); |
3169 | |
3170 | mSerialA.OpenModule(dev_id); |
3171 | tmp_ret |= mSerialA.start(); |
3172 | } |
3173 | } else if (dev_id == SERIAL_B) { |
3174 | if (switch_val == 0) { |
3175 | tmp_ret |= mSerialB.stop(); |
3176 | tmp_ret |= mSerialB.CloseModule(); |
3177 | } else { |
3178 | mSerialB.OpenModule(dev_id); |
3179 | tmp_ret = mSerialB.start(); |
3180 | } |
3181 | } else if (dev_id == SERIAL_C) { |
3182 | if (switch_val == 0) { |
3183 | tmp_ret |= mSerialC.stop(); |
3184 | tmp_ret |= mSerialC.CloseModule(); |
3185 | } else { |
3186 | mSerialC.OpenModule(dev_id); |
3187 | tmp_ret = mSerialC.start(); |
3188 | } |
3189 | } |
3190 | |
3191 | return tmp_ret; |
3192 | } |
3193 | |
3194 | int CTv::SendSerialData(int dev_id, int data_len, unsigned char data_buf[]) |
3195 | { |
3196 | int tmp_ret = 0; |
3197 | |
3198 | if (dev_id == SERIAL_A) { |
3199 | tmp_ret = mSerialA.sendData(data_len, data_buf); |
3200 | } else if (dev_id == SERIAL_B) { |
3201 | tmp_ret = mSerialB.sendData(data_len, data_buf); |
3202 | } else if (dev_id == SERIAL_C) { |
3203 | tmp_ret = mSerialC.sendData(data_len, data_buf); |
3204 | } |
3205 | |
3206 | return tmp_ret; |
3207 | } |
3208 | |
3209 | int CTv::ChannelExport(const char *destPath) |
3210 | { |
3211 | char tmp[256]; |
3212 | FILE *fp = NULL; |
3213 | if (destPath == NULL) { |
3214 | destPath = "/storage/external_storage/sda1/"; |
3215 | } |
3216 | |
3217 | sprintf(tmp, "cp /param/dtv.db %s", destPath); |
3218 | if (system(tmp) >= 0) { |
3219 | LOGD("%s, copy dtv.db from /param to udisk success !", __FUNCTION__); |
3220 | system("sync"); |
3221 | fp = fopen(destPath, "r"); |
3222 | if (fp != NULL) { |
3223 | fclose(fp); |
3224 | fp = NULL; |
3225 | return 0; |
3226 | } |
3227 | } |
3228 | |
3229 | return -1; |
3230 | } |
3231 | |
3232 | int CTv::ChannelImport(const char *srcPath) |
3233 | { |
3234 | if (srcPath == NULL) { |
3235 | srcPath = "/storage/external_storage/sda1/dvb.db"; |
3236 | } |
3237 | |
3238 | if (Tv_Utils_IsFileExist(srcPath)) { |
3239 | char tmp[256]; |
3240 | const char *destPath = config_get_str(CFG_SECTION_TV, "tv.channel.db", (char *) "/param/dtv.db"); |
3241 | |
3242 | LOGD("%s, file exist !" , srcPath); |
3243 | CTvDatabase::GetTvDb()->UnInitTvDb(); |
3244 | sprintf(tmp, "rm %s", destPath); |
3245 | if (system(tmp) >= 0) { |
3246 | LOGD("%s, rm %s success !", __FUNCTION__, destPath); |
3247 | memset(tmp, 0, sizeof(tmp)); |
3248 | sprintf(tmp, "cp %s %s", srcPath, destPath); |
3249 | if (system(tmp) >= 0) { |
3250 | LOGD("%s, copy to %s success !", srcPath, destPath); |
3251 | memset(tmp, 0, sizeof(tmp)); |
3252 | sprintf(tmp, "chmod 777 %s", destPath); |
3253 | if (system(tmp) >= 0) { |
3254 | LOGD("chmod 777 %s success !", destPath); |
3255 | system("sync"); |
3256 | CTvDatabase::GetTvDb()->InitTvDb(TV_DB_PATH); |
3257 | return 0; |
3258 | } else { |
3259 | LOGD("%s, %s chmod failed !", __FUNCTION__, destPath); |
3260 | return -1; |
3261 | } |
3262 | } else { |
3263 | LOGD("%s, copy dtv.db from udisk to %s failed !", __FUNCTION__, destPath); |
3264 | return -1; |
3265 | } |
3266 | } else { |
3267 | LOGD("%s, rm %s failed !", __FUNCTION__, destPath); |
3268 | return -2; |
3269 | } |
3270 | } else { |
3271 | LOGD("%s, dtv.db file does not exist in the udisk!" , srcPath); |
3272 | return -2; |
3273 | } |
3274 | } |
3275 | |
3276 | int CTv::Tv_GetProjectInfo(project_info_t *ptrInfo) |
3277 | { |
3278 | return GetProjectInfo(ptrInfo, fbcIns); |
3279 | } |
3280 | |
3281 | int CTv::Tv_GetPlatformType() |
3282 | { |
3283 | return mHdmiOutFbc ? 1 : 0; |
3284 | } |
3285 | |
3286 | int CTv::Tv_HandeHDMIEDIDFilePathConfig() |
3287 | { |
3288 | char edid_path[256]; |
3289 | char edid_path_cfg[256]; |
3290 | bool fileExist = false; |
3291 | |
3292 | const char *value = config_get_str(CFG_SECTION_TV, "ssm.handle.hdmi.edid.en", "null"); |
3293 | if (strtoul(value, NULL, 10) == 1) { |
3294 | LOGD( "%s, get config [ssm.handle.hdmi.edid.en]:[%s]\n", __FUNCTION__, value); |
3295 | //get hdmi edid use mode |
3296 | char propValue[256] = {0}; |
3297 | property_get("ubootenv.var.outputmode", propValue, "null"); |
3298 | LOGD( "%s, get property [ubootenv.var.outputmode]:[%s]\n", __FUNCTION__, propValue); |
3299 | if (strcmp(propValue, "null") != 0) { |
3300 | fileExist = true; |
3301 | |
3302 | config_set_str ( CFG_SECTION_TV, CS_HDMI_EDID_USE_CFG, propValue); |
3303 | //set file's path for hdmi edid of each port |
3304 | for (int i = 1; i <= SSM_HDMI_PORT_MAX; i++) { |
3305 | memset( edid_path, '\0', 256); |
3306 | memset( edid_path_cfg, '\0', 256); |
3307 | sprintf(edid_path, "/system/etc/%s_port%d.bin", propValue, i); |
3308 | sprintf(edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i); |
3309 | if (access(edid_path, 0) < 0) { |
3310 | fileExist = false; |
3311 | break; |
3312 | } |
3313 | config_set_str(CFG_SECTION_TV, edid_path_cfg, edid_path); |
3314 | } |
3315 | } |
3316 | |
3317 | if (!fileExist) { |
3318 | //set default hdmi edid |
3319 | config_set_str(CFG_SECTION_TV, CS_HDMI_EDID_USE_CFG, "hdmi_edid"); |
3320 | //set file's path for hdmi edid of each port |
3321 | for (int i = 1; i <= SSM_HDMI_PORT_MAX; i++) { |
3322 | memset(edid_path, '\0', 256); |
3323 | memset(edid_path_cfg, '\0', 256); |
3324 | sprintf(edid_path, "/system/etc/%s_port%d.bin", "hdmi_edid", i); |
3325 | sprintf(edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i); |
3326 | |
3327 | value = config_get_str(CFG_SECTION_TV, edid_path_cfg, "null"); |
3328 | if (strcmp(value, edid_path) != 0) { |
3329 | config_set_str(CFG_SECTION_TV, edid_path_cfg, edid_path); |
3330 | } |
3331 | } |
3332 | } |
3333 | |
3334 | mSetHdmiEdid = true; |
3335 | } |
3336 | return 0; |
3337 | } |
3338 | |
3339 | int CTv::Tv_SetDDDRCMode(tv_source_input_t source_input) |
3340 | { |
3341 | if (source_input == SOURCE_DTV) { |
3342 | if (GetPlatformHaveDDFlag() == 1) { |
3343 | Tv_Utils_SetFileAttrStr("/sys/class/audiodsp/ac3_drc_control", (char *)"drcmode 3"); |
3344 | } |
3345 | } else { |
3346 | if (GetPlatformHaveDDFlag() == 1) { |
3347 | Tv_Utils_SetFileAttrStr("/sys/class/audiodsp/ac3_drc_control", (char *)"drcmode 2"); |
3348 | } |
3349 | } |
3350 | return 0; |
3351 | } |
3352 | |
3353 | //PQ |
3354 | int CTv::Tv_SetBrightness ( int brightness, tv_source_input_type_t source_type, int is_save ) |
3355 | { |
3356 | return mVpp.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); |
3357 | } |
3358 | |
3359 | int CTv::Tv_GetBrightness ( tv_source_input_type_t source_type ) |
3360 | { |
3361 | return mVpp.GetBrightness((tv_source_input_type_t)source_type); |
3362 | } |
3363 | |
3364 | int CTv::Tv_SaveBrightness ( int brightness, tv_source_input_type_t source_type ) |
3365 | { |
3366 | return SSMSaveBrightness ( source_type, brightness ); |
3367 | } |
3368 | |
3369 | int CTv::Tv_SetContrast ( int contrast, tv_source_input_type_t source_type, int is_save ) |
3370 | { |
3371 | return mVpp.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); |
3372 | } |
3373 | |
3374 | int CTv::Tv_GetContrast ( tv_source_input_type_t source_type ) |
3375 | { |
3376 | return mVpp.GetContrast((tv_source_input_type_t)source_type); |
3377 | } |
3378 | |
3379 | int CTv::Tv_SaveContrast ( int contrast, tv_source_input_type_t source_type ) |
3380 | { |
3381 | return SSMSaveContrast ( source_type, contrast ); |
3382 | } |
3383 | |
3384 | int CTv::Tv_SetSaturation ( int satuation, tv_source_input_type_t source_type, tvin_sig_fmt_t fmt, int is_save ) |
3385 | { |
3386 | return mVpp.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); |
3387 | } |
3388 | |
3389 | int CTv::Tv_GetSaturation ( tv_source_input_type_t source_type ) |
3390 | { |
3391 | return mVpp.GetSaturation((tv_source_input_type_t)source_type); |
3392 | } |
3393 | |
3394 | int CTv::Tv_SaveSaturation ( int satuation, tv_source_input_type_t source_type ) |
3395 | { |
3396 | return SSMSaveSaturation ( source_type, satuation ); |
3397 | } |
3398 | |
3399 | int CTv::Tv_SetHue ( int hue, tv_source_input_type_t source_type, tvin_sig_fmt_t fmt, int is_save ) |
3400 | { |
3401 | return mVpp.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); |
3402 | } |
3403 | |
3404 | int CTv::Tv_GetHue ( tv_source_input_type_t source_type ) |
3405 | { |
3406 | return mVpp.GetHue((tv_source_input_type_t)source_type); |
3407 | } |
3408 | |
3409 | int CTv::Tv_SaveHue ( int hue, tv_source_input_type_t source_type ) |
3410 | { |
3411 | return SSMSaveHue ( source_type, hue ); |
3412 | } |
3413 | |
3414 | int CTv::Tv_SetPQMode ( vpp_picture_mode_t mode, tv_source_input_type_t source_type, int is_save ) |
3415 | { |
3416 | return mVpp.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); |
3417 | } |
3418 | |
3419 | vpp_picture_mode_t CTv::Tv_GetPQMode ( tv_source_input_type_t source_type ) |
3420 | { |
3421 | return mVpp.GetPQMode((tv_source_input_type_t)source_type); |
3422 | } |
3423 | |
3424 | int CTv::Tv_SavePQMode ( vpp_picture_mode_t mode, tv_source_input_type_t source_type ) |
3425 | { |
3426 | return mVpp.SavePQMode ( mode, source_type ); |
3427 | } |
3428 | |
3429 | int CTv::Tv_SetSharpness ( int value, tv_source_input_type_t source_type, int en, int is_save ) |
3430 | { |
3431 | return mVpp.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); |
3432 | } |
3433 | |
3434 | int CTv::Tv_GetSharpness ( tv_source_input_type_t source_type ) |
3435 | { |
3436 | return mVpp.GetSharpness((tv_source_input_type_t)source_type); |
3437 | } |
3438 | |
3439 | int CTv::Tv_SaveSharpness ( int value, tv_source_input_type_t source_type ) |
3440 | { |
3441 | return SSMSaveSharpness ( source_type, value ); |
3442 | } |
3443 | |
3444 | int CTv::Tv_SetBacklight ( int value, tv_source_input_type_t source_type, int is_save ) |
3445 | { |
3446 | if (mHdmiOutFbc) { |
3447 | return Tv_FactorySet_FBC_Backlight(value); |
3448 | } else { |
3449 | return mVpp.SetBacklight(value, (tv_source_input_type_t)source_type, is_save); |
3450 | } |
3451 | } |
3452 | |
3453 | int CTv::Tv_GetBacklight ( tv_source_input_type_t source_type ) |
3454 | { |
3455 | if (mHdmiOutFbc) { |
3456 | return Tv_FactoryGet_FBC_Backlight(); |
3457 | } else { |
3458 | return mVpp.GetBacklight((tv_source_input_type_t)source_type); |
3459 | } |
3460 | } |
3461 | |
3462 | int CTv::Tv_SaveBacklight ( int value, tv_source_input_type_t source_type ) |
3463 | { |
3464 | return mVpp.SaveBacklight ( value, source_type ); |
3465 | } |
3466 | |
3467 | int CTv::Tv_SetBacklight_Switch ( int value ) |
3468 | { |
3469 | if (mHdmiOutFbc) { |
3470 | return Tv_FactorySet_FBC_backlight_onoff(value); |
3471 | } else { |
3472 | return mVpp.VPP_SetBackLight_Switch(value); |
3473 | } |
3474 | } |
3475 | |
3476 | int CTv::Tv_GetBacklight_Switch ( void ) |
3477 | { |
3478 | if (mHdmiOutFbc) { |
3479 | return Tv_FactoryGet_FBC_backlight_onoff(); |
3480 | } else { |
3481 | return mVpp.VPP_GetBackLight_Switch(); |
3482 | } |
3483 | } |
3484 | |
3485 | int CTv::Tv_SetColorTemperature ( vpp_color_temperature_mode_t mode, tv_source_input_type_t source_type, int is_save ) |
3486 | { |
3487 | if (mHdmiOutFbc) { |
3488 | return Tv_FactorySet_FBC_ColorTemp_Mode(mode); |
3489 | } else { |
3490 | return mVpp.SetColorTemperature((vpp_color_temperature_mode_t)mode, (tv_source_input_type_t)source_type, is_save); |
3491 | } |
3492 | } |
3493 | |
3494 | vpp_color_temperature_mode_t CTv::Tv_GetColorTemperature ( tv_source_input_type_t source_type ) |
3495 | { |
3496 | if (mHdmiOutFbc) { |
3497 | return (vpp_color_temperature_mode_t)Tv_FactoryGet_FBC_ColorTemp_Mode(); |
3498 | } else { |
3499 | return mVpp.GetColorTemperature((tv_source_input_type_t)source_type); |
3500 | } |
3501 | } |
3502 | |
3503 | int CTv::Tv_SaveColorTemperature ( vpp_color_temperature_mode_t mode, tv_source_input_type_t source_type ) |
3504 | { |
3505 | return mVpp.SaveColorTemp ( mode, source_type ); |
3506 | } |
3507 | |
3508 | int CTv::Tv_SetDisplayMode ( vpp_display_mode_t mode, tv_source_input_type_t source_type, tvin_sig_fmt_t fmt, int is_save ) |
3509 | { |
3510 | int ret = 0; |
3511 | if (m_mode_3d == VIDEO_3D_MODE_DISABLE) { |
3512 | ret = SetDisplayMode((vpp_display_mode_t)mode, (tv_source_input_type_t)source_type, (tvin_sig_fmt_t)fmt); |
3513 | } else { //3D |
3514 | ret = SetDisplayMode(VPP_DISPLAY_MODE_PERSON, (tv_source_input_type_t)source_type, (tvin_sig_fmt_t)fmt); |
3515 | } |
3516 | if (ret == 0) { |
3517 | if (is_save == 1) { |
3518 | ret = ret | SSMSaveDisplayMode ( source_type, (int)mode ); |
3519 | } |
3520 | } |
3521 | return ret; |
3522 | } |
3523 | |
3524 | int CTv::SetDisplayMode ( vpp_display_mode_t display_mode, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt ) |
3525 | { |
3526 | LOGD("SetDisplayMode, display_mode = %d, source_type = %d fmt = %d tranfmt = %d\n", display_mode, source_type, sig_fmt, mSigDetectThread.getCurSigInfo().trans_fmt); |
3527 | |
3528 | tvin_cutwin_t cutwin = mVpp.GetOverscan ( source_type, sig_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt); |
3529 | LOGD("SetDisplayMode , get crop %d %d %d %d \n", cutwin.vs, cutwin.hs, cutwin.ve, cutwin.he); |
3530 | int video_screen_mode = CAv::VIDEO_WIDEOPTION_16_9; |
3531 | tvin_window_pos_t win_pos; |
3532 | int display_resolution = Vpp_GetDisplayResolutionInfo(&win_pos); |
3533 | |
3534 | switch ( display_mode ) { |
3535 | case VPP_DISPLAY_MODE_169: |
3536 | video_screen_mode = CAv::VIDEO_WIDEOPTION_16_9; |
3537 | break; |
3538 | case VPP_DISPLAY_MODE_MODE43: |
3539 | video_screen_mode = CAv::VIDEO_WIDEOPTION_4_3; |
3540 | break; |
3541 | case VPP_DISPLAY_MODE_NORMAL: |
3542 | video_screen_mode = CAv::VIDEO_WIDEOPTION_NORMAL; |
3543 | break; |
3544 | case VPP_DISPLAY_MODE_FULL: |
3545 | video_screen_mode = CAv::VIDEO_WIDEOPTION_NONLINEAR; |
3546 | mVpp.VPP_SetNonLinearFactor ( 20 ); |
3547 | //mVpp.VPP_SetNonLinearFactor ( 20 ); |
3548 | break; |
3549 | case VPP_DISPLAY_MODE_CROP_FULL: |
3550 | cutwin.vs = 0; |
3551 | cutwin.hs = 0; |
3552 | cutwin.ve = 0; |
3553 | cutwin.he = 0; |
3554 | break; |
3555 | case VPP_DISPLAY_MODE_NOSCALEUP: |
3556 | video_screen_mode = CAv::VIDEO_WIDEOPTION_NORMAL_NOSCALEUP; |
3557 | break; |
3558 | case VPP_DISPLAY_MODE_FULL_REAL: |
3559 | video_screen_mode = CAv::VIDEO_WIDEOPTION_16_9; //added for N360 by haifeng.liu |
3560 | break; |
3561 | case VPP_DISPLAY_MODE_PERSON: |
3562 | video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH; |
3563 | cutwin.vs = cutwin.vs + 20; |
3564 | cutwin.ve = cutwin.ve + 20; |
3565 | break; |
3566 | case VPP_DISPLAY_MODE_MOVIE: |
3567 | video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH; |
3568 | cutwin.vs = cutwin.vs + 40; |
3569 | cutwin.ve = cutwin.ve + 40; |
3570 | break; |
3571 | case VPP_DISPLAY_MODE_CAPTION: |
3572 | video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH; |
3573 | cutwin.vs = cutwin.vs + 55; |
3574 | cutwin.ve = cutwin.ve + 55; |
3575 | break; |
3576 | case VPP_DISPLAY_MODE_ZOOM: |
3577 | video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH; |
3578 | cutwin.vs = cutwin.vs + 70; |
3579 | cutwin.ve = cutwin.ve + 70; |
3580 | break; |
3581 | default: |
3582 | break; |
3583 | } |
3584 | if (source_type == SOURCE_TYPE_DTV || source_type == SOURCE_TYPE_MPEG) { |
3585 | cutwin.vs = cutwin.vs + 12; |
3586 | cutwin.ve = cutwin.ve + 12; |
3587 | cutwin.hs = cutwin.hs + 12; |
3588 | cutwin.he = cutwin.he + 12; |
3589 | } |
3590 | if (source_type == SOURCE_TYPE_HDMI) { |
3591 | if ((IsDVISignal()) || (mTvin.GetITContent() == 1) || |
3592 | (display_mode == VPP_DISPLAY_MODE_FULL_REAL)) { |
3593 | cutwin.vs = 0; |
3594 | cutwin.hs = 0; |
3595 | cutwin.ve = 0; |
3596 | cutwin.he = 0; |
3597 | } |
3598 | } |
3599 | |
3600 | //mAv.setVideoAxis ( win_pos.x1, win_pos.y1, win_pos.x2, win_pos.y2 ); |
3601 | mAv.setVideoScreenMode(video_screen_mode); |
3602 | mVpp.VPP_SetVideoCrop(cutwin.vs, cutwin.hs, cutwin.ve, cutwin.he); |
3603 | return 0; |
3604 | } |
3605 | |
3606 | vpp_display_mode_t CTv::Tv_GetDisplayMode ( tv_source_input_type_t source_type ) |
3607 | { |
3608 | return mVpp.GetDisplayMode((tv_source_input_type_t)source_type); |
3609 | } |
3610 | |
3611 | int CTv::Tv_SaveDisplayMode ( vpp_display_mode_t mode, tv_source_input_type_t source_type ) |
3612 | { |
3613 | return SSMSaveDisplayMode ( source_type, (int)mode ); |
3614 | } |
3615 | |
3616 | int CTv::Tv_SetNoiseReductionMode ( vpp_noise_reduction_mode_t mode, tv_source_input_type_t source_type, int is_save ) |
3617 | { |
3618 | return mVpp.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); |
3619 | } |
3620 | |
3621 | int CTv::Tv_SaveNoiseReductionMode ( vpp_noise_reduction_mode_t mode, tv_source_input_type_t source_type ) |
3622 | { |
3623 | return mVpp.SaveNoiseReductionMode ( mode, source_type ); |
3624 | } |
3625 | |
3626 | int CTv::Tv_Set2k4k_ScalerUp_Mode ( int value ) |
3627 | { |
3628 | int ret = 0, fmt_hd_sd = 0; |
3629 | int nodeVal = 0; |
3630 | char s[8]; |
3631 | |
3632 | LOGD("%s, value [%d]\n", __FUNCTION__ , value); |
3633 | |
3634 | if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI && |
3635 | CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_AV && |
3636 | CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_TV) { |
3637 | int fd = open("/sys/class/video/frame_height", O_RDONLY); |
3638 | if (fd <= 0) { |
3639 | LOGE("open /sys/class/video/frame_height ERROR!!error = -%s- \n", strerror ( errno )); |
3640 | return -1; |
3641 | } |
3642 | read(fd, s, sizeof(s)); |
3643 | close(fd); |
3644 | nodeVal = atoi(s); |
3645 | if (nodeVal < 900) { |
3646 | fmt_hd_sd = 0; |
3647 | } else { |
3648 | fmt_hd_sd = 1; |
3649 | } |
3650 | } else if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) { |
3651 | if (isSDFmtInHdmi()) { |
3652 | fmt_hd_sd = 0; |
3653 | } else { |
3654 | fmt_hd_sd = 1; |
3655 | } |
3656 | } else if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_AV || |
3657 | CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_TV) { |
3658 | fmt_hd_sd = 0; |
3659 | } |
3660 | |
3661 | switch (value) { |
3662 | case 1: // on |
3663 | if (fmt_hd_sd) { |
3664 | ret = Tv_Utils_SetFileAttrStr("/sys/class/video/video_scaler_path_sel", (char *)"0"); |
3665 | //LOGD("%s, enable, set 0.\n", __FUNCTION__); |
3666 | } else { |
3667 | ret = Tv_Utils_SetFileAttrStr("/sys/class/video/video_scaler_path_sel", (char *)"1"); |
3668 | } |
3669 | break; |
3670 | |
3671 | case 0: // off |
3672 | default: |
3673 | if (fmt_hd_sd) { |
3674 | ret = Tv_Utils_SetFileAttrStr("/sys/class/video/video_scaler_path_sel", (char *)"1"); |
3675 | //LOGD("%s, disable, set 1.\n", __FUNCTION__); |
3676 | } else { |
3677 | ret = Tv_Utils_SetFileAttrStr("/sys/class/video/video_scaler_path_sel", (char *)"0"); |
3678 | //LOGD("%s, disable, set 0.\n", __FUNCTION__); |
3679 | } |
3680 | break; |
3681 | } |
3682 | return ret; |
3683 | } |
3684 | |
3685 | int CTv::Tv_Get2k4k_ScalerUp_Mode ( void ) |
3686 | { |
3687 | char attrV[64]; |
3688 | int ret = 0, fmt_hd_sd = 0; |
3689 | int nodeVal = 0; |
3690 | char s[8]; |
3691 | |
3692 | memset (attrV, '\0', 64); |
3693 | |
3694 | if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI && |
3695 | CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_AV && |
3696 | CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_TV) { |
3697 | int fd = open("/sys/class/video/frame_height", O_RDONLY); |
3698 | if (fd <= 0) { |
3699 | LOGE("open /sys/class/video/frame_height ERROR!!error = -%s- \n", strerror ( errno )); |
3700 | return -1; |
3701 | } |
3702 | read(fd, s, sizeof(s)); |
3703 | close(fd); |
3704 | nodeVal = atoi(s); |
3705 | if (nodeVal < 900) { |
3706 | fmt_hd_sd = 0; |
3707 | } else { |
3708 | fmt_hd_sd = 1; |
3709 | } |
3710 | } else if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) { |
3711 | if (isSDFmtInHdmi()) { |
3712 | fmt_hd_sd = 0; |
3713 | } else { |
3714 | fmt_hd_sd = 1; |
3715 | } |
3716 | } else if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_AV || CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_TV) { |
3717 | fmt_hd_sd = 0; |
3718 | } |
3719 | |
3720 | Tv_Utils_GetFileAttrStr("/sys/class/video/video_scaler_path_sel", 64, attrV); |
3721 | //LOGD("%s, 11111111scaler_path_sel[%s].\n", __FUNCTION__ , attrV); |
3722 | if (strncasecmp(attrV, "1", strlen ("1")) == 0) { |
3723 | if (fmt_hd_sd) { |
3724 | ret = 0; |
3725 | } else { |
3726 | ret = 1; |
3727 | } |
3728 | } else if (strncasecmp(attrV, "0", strlen ("0")) == 0) { |
3729 | if (fmt_hd_sd) { |
3730 | ret = 1; |
3731 | } else { |
3732 | ret = 0; |
3733 | } |
3734 | } else { |
3735 | ret = -1; |
3736 | } |
3737 | |
3738 | return ret; |
3739 | } |
3740 | |
3741 | int CTv::Tv_SetSplitScreenDemoStatus(tv_source_input_type_t source_type, int onoff_status) |
3742 | { |
3743 | int ret = 0; |
3744 | LOGD("%s, split screen demo status source[%d],onoff_stauts[%d]\n", __FUNCTION__ , source_type, onoff_status); |
3745 | if (1 == onoff_status) { |
3746 | ret = Tv_Utils_SetFileAttrStr("/sys/class/amlogic/debug", (char *)"w 0x503c0 v 0x31d6");//sharpness screen left |
3747 | ret |= Tv_Utils_SetFileAttrStr("/sys/class/amlogic/debug", (char *)"w 0x07 v 0x174d");//nr screen left |
3748 | } else if (0 == onoff_status) { |
3749 | ret = Tv_Utils_SetFileAttrStr("/sys/class/amlogic/debug", (char *)"w 0x503c0 v 0x31d6");//sharpness screen left |
3750 | ret |= Tv_Utils_SetFileAttrStr("/sys/class/amlogic/debug", (char *)"w 0x07 v 0x174d");//nr screen left |
3751 | } |
3752 | |
3753 | if (fbcIns != NULL && 0 == ret) { |
3754 | ret |= fbcIns->cfbc_SET_SPLIT_SCREEN_DEMO(COMM_DEV_SERIAL, onoff_status); |
3755 | } |
3756 | |
3757 | return ret; |
3758 | } |
3759 | |
3760 | int CTv::Tv_GetSplitScreenDemoStatus(tv_source_input_type_t source_type) |
3761 | { |
3762 | source_type = source_type; |
3763 | return 0; |
3764 | } |
3765 | |
3766 | vpp_noise_reduction_mode_t CTv::Tv_GetNoiseReductionMode ( tv_source_input_type_t source_type ) |
3767 | { |
3768 | return mVpp.GetNoiseReductionMode((tv_source_input_type_t)source_type); |
3769 | } |
3770 | |
3771 | /** |
3772 | * @parameter mode : 0:sharpness; 1:NR |
3773 | * |
3774 | 1.sharpness分屏(可以控制宽度) |
3775 | 分屏大小 寄存器范围是0x50000 冿x50780,左效果的范围越来越大?0x70780 冿x70000也是一? |
3776 | 左右调换控制 bit 17. 开僿控?bit 16. 0-11bit 是控制宽度的。范围是0-0x780?920像素? |
3777 | 左做效果处理 echo w 0x503c0 v 0x31d6 > /sys/class/amlogic/debug |
3778 | 右做效果处理 echo w 0x703c0 v 0x31d6 > /sys/class/amlogic/debug |
3779 | echo w 0x403c0 v 0x31d6 > /sys/class/amlogic/debug |
3780 | |
3781 | 2. NR分屏(不能控制宽度) |
3782 | 左做效果处理 echo w 0x07 v 0x174d > /sys /class/amlogic/debug |
3783 | 右做效果处理 echo w 0x70 v 0x174d > /sys /class/amlogic/debug |
3784 | ? echo w 0x77 v 0x174d > /sys/class/amlogic/debug |
3785 | */ |
3786 | int CTv::Tv_SplitScreenEffect(int mode, int width, int reverse) |
3787 | { |
3788 | int ret = -1; |
3789 | |
3790 | if (mode == 0) { |
3791 | if (width == 0) {//close |
3792 | ret = mVpp.VPP_SplitScreenEffect(0x403c0, 0x31d6); |
3793 | } else { |
3794 | int val = 0; |
3795 | if (reverse == 0) {//left effect |
3796 | val = width + 0x50000; |
3797 | } else {//right effect |
3798 | val = 0x70780 - width; |
3799 | } |
3800 | ret = mVpp.VPP_SplitScreenEffect(val, 0x31d6); |
3801 | } |
3802 | } else if (mode == 1) { |
3803 | if (width == 0) {//close |
3804 | ret = mVpp.VPP_SplitScreenEffect(0x77, 0x174d); |
3805 | } else { |
3806 | if (reverse == 0) |
3807 | ret = mVpp.VPP_SplitScreenEffect(0x07, 0x174d); |
3808 | else |
3809 | ret = mVpp.VPP_SplitScreenEffect(0x70, 0x174d); |
3810 | } |
3811 | } else if (mode == 2) { |
3812 | } |
3813 | |
3814 | return ret; |
3815 | } |
3816 | |
3817 | int CTv::Tv_FactorySetPQMode_Brightness ( int source_type, int pq_mode, int brightness ) |
3818 | { |
3819 | return mVpp.FactorySetPQMode_Brightness(source_type, pq_mode, brightness); |
3820 | } |
3821 | |
3822 | int CTv::Tv_FactoryGetPQMode_Brightness ( int source_type, int pq_mode ) |
3823 | { |
3824 | return mVpp.FactoryGetPQMode_Brightness(source_type, pq_mode); |
3825 | } |
3826 | |
3827 | int CTv::Tv_FactorySetPQMode_Contrast ( int source_type, int pq_mode, int contrast ) |
3828 | { |
3829 | return mVpp.FactorySetPQMode_Contrast(source_type, pq_mode, contrast); |
3830 | } |
3831 | |
3832 | int CTv::Tv_FactoryGetPQMode_Contrast ( int source_type, int pq_mode ) |
3833 | { |
3834 | return mVpp.FactoryGetPQMode_Contrast(source_type, pq_mode); |
3835 | } |
3836 | |
3837 | int CTv::Tv_FactorySetPQMode_Saturation ( int source_type, int pq_mode, int saturation ) |
3838 | { |
3839 | return mVpp.FactorySetPQMode_Saturation(source_type, pq_mode, saturation); |
3840 | } |
3841 | |
3842 | int CTv::Tv_FactoryGetPQMode_Saturation ( int source_type, int pq_mode ) |
3843 | { |
3844 | return mVpp.FactoryGetPQMode_Saturation(source_type, pq_mode); |
3845 | } |
3846 | |
3847 | int CTv::Tv_FactorySetPQMode_Hue ( int source_type, int pq_mode, int hue ) |
3848 | { |
3849 | return mVpp.FactorySetPQMode_Hue(source_type, pq_mode, hue); |
3850 | } |
3851 | |
3852 | int CTv::Tv_FactoryGetPQMode_Hue ( int source_type, int pq_mode ) |
3853 | { |
3854 | return mVpp.FactoryGetPQMode_Hue(source_type, pq_mode); |
3855 | } |
3856 | |
3857 | int CTv::Tv_FactorySetPQMode_Sharpness ( int source_type, int pq_mode, int sharpness ) |
3858 | { |
3859 | return mVpp.FactorySetPQMode_Sharpness(source_type, pq_mode, sharpness); |
3860 | } |
3861 | |
3862 | int CTv::Tv_FactoryGetPQMode_Sharpness ( int source_type, int pq_mode ) |
3863 | { |
3864 | return mVpp.FactoryGetPQMode_Sharpness(source_type, pq_mode); |
3865 | } |
3866 | |
3867 | int CTv::GetColorTemperatureParams ( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params ) |
3868 | { |
3869 | if (mHdmiOutFbc) { |
3870 | int ret = Tv_FactoryGet_FBC_ColorTemp_Batch((vpp_color_temperature_mode_t)Tempmode, params); |
3871 | params->r_gain = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params->r_gain); |
3872 | params->g_gain = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params->g_gain); |
3873 | params->b_gain = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params->b_gain); |
3874 | params->r_post_offset = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params->r_post_offset); |
3875 | params->g_post_offset = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params->g_post_offset); |
3876 | params->b_post_offset = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params->b_post_offset); |
3877 | return ret; |
3878 | } else { |
3879 | return mVpp.GetColorTemperatureParams(Tempmode, params); |
3880 | } |
3881 | } |
3882 | |
3883 | int CTv::Tv_FactorySetTestPattern ( int pattern ) |
3884 | { |
3885 | switch ( pattern ) { |
3886 | case VPP_TEST_PATTERN_NONE: |
3887 | mAv.SetVideoScreenColor ( 3, 16, 128, 128 ); |
3888 | break; |
3889 | |
3890 | case VPP_TEST_PATTERN_RED: |
3891 | mAv.SetVideoScreenColor ( 0, 81, 90, 240 ); |
3892 | break; |
3893 | |
3894 | case VPP_TEST_PATTERN_GREEN: |
3895 | mAv.SetVideoScreenColor ( 0, 145, 54, 34 ); |
3896 | break; |
3897 | |
3898 | case VPP_TEST_PATTERN_BLUE: |
3899 | mAv.SetVideoScreenColor ( 0, 41, 240, 110 ); |
3900 | break; |
3901 | |
3902 | case VPP_TEST_PATTERN_WHITE: |
3903 | mAv.SetVideoScreenColor ( 0, 235, 128, 128 ); |
3904 | break; |
3905 | |
3906 | case VPP_TEST_PATTERN_BLACK: |
3907 | mAv.SetVideoScreenColor ( 0, 16, 128, 128 ); |
3908 | break; |
3909 | |
3910 | default: |
3911 | return -1; |
3912 | } |
3913 | return SSMSaveTestPattern ( pattern ); |
3914 | } |
3915 | |
3916 | int CTv::Tv_FactoryGetTestPattern ( void ) |
3917 | { |
3918 | return mVpp.FactoryGetTestPattern(); |
3919 | } |
3920 | |
3921 | int CTv::Tv_FactorySetScreenColor ( int vdin_blending_mask, int y, int u, int v ) |
3922 | { |
3923 | return mAv.SetVideoScreenColor ( vdin_blending_mask, y, u, v ); |
3924 | } |
3925 | |
3926 | int CTv::Tv_FactoryResetPQMode ( void ) |
3927 | { |
3928 | return mVpp.FactoryResetPQMode(); |
3929 | } |
3930 | |
3931 | int CTv::Tv_FactoryResetColorTemp ( void ) |
3932 | { |
3933 | return mVpp.FactoryResetColorTemp(); |
3934 | } |
3935 | |
3936 | int CTv::Tv_FactorySetParamsDefault ( void ) |
3937 | { |
3938 | return mVpp.FactorySetParamsDefault(); |
3939 | } |
3940 | |
3941 | int CTv::Tv_FactorySetDDRSSC ( int step ) |
3942 | { |
3943 | return mVpp.FactorySetDDRSSC(step); |
3944 | } |
3945 | |
3946 | int CTv::Tv_FactoryGetDDRSSC ( void ) |
3947 | { |
3948 | return mVpp.FactoryGetDDRSSC(); |
3949 | } |
3950 | |
3951 | int CTv::Tv_FactorySetLVDSSSC ( int step ) |
3952 | { |
3953 | return mVpp.FactorySetLVDSSSC(step); |
3954 | } |
3955 | |
3956 | int CTv::Tv_FactoryGetLVDSSSC ( void ) |
3957 | { |
3958 | return mVpp.FactoryGetLVDSSSC(); |
3959 | } |
3960 | |
3961 | void CTv::Tv_Spread_Spectrum() |
3962 | { |
3963 | int value = 0; |
3964 | value = mVpp.FactoryGetLVDSSSC(); |
3965 | mVpp.FactorySetLVDSSSC(value); |
3966 | } |
3967 | |
3968 | int CTv::Tv_FactorySetNolineParams ( int noline_params_type, int source_type, noline_params_t noline_params ) |
3969 | { |
3970 | return mVpp.FactorySetNolineParams(noline_params_type, source_type, noline_params); |
3971 | } |
3972 | |
3973 | noline_params_t CTv::Tv_FactoryGetNolineParams ( int noline_params_type, int source_type ) |
3974 | { |
3975 | return mVpp.FactoryGetNolineParams(noline_params_type, source_type); |
3976 | } |
3977 | |
3978 | int CTv::Tv_FactorySetOverscan ( int source_type, int fmt, int status_3d, int trans_fmt, tvin_cutwin_t cutwin_t ) |
3979 | { |
3980 | //tvin_cutwin_t cutwin_t = mVpp.Tv_FactoryGetOverscan(source_type, fmt, status_3d, trans_fmt); |
3981 | mVpp.FactorySetOverscan(source_type, fmt, status_3d, trans_fmt, cutwin_t); |
3982 | //} else { |
3983 | #if 0 |
3984 | char val_buf[256]; |
3985 | memset(val_buf, '\0', 256); |
3986 | LOGD("%s,%d: %d,%d,%d,%d", __FUNCTION__, __LINE__, ( int ) cutwin_t.vs, ( int ) cutwin_t.hs, ( int ) cutwin_t.ve, ( int ) cutwin_t.he); |
3987 | sprintf(val_buf, "%d,%d,%d,%d", ( int ) cutwin_t.vs, ( int ) cutwin_t.hs, ( int ) cutwin_t.ve, ( int ) cutwin_t.he ); |
3988 | config_set_str(CFG_SECTION_TV, "vpp.overscan.dtv", val_buf); |
3989 | //} |
3990 | #endif |
3991 | return mVpp.VPP_SetVideoCrop ( ( int ) cutwin_t.vs, ( int ) cutwin_t.hs, ( int ) cutwin_t.ve, ( int ) cutwin_t.he ); |
3992 | } |
3993 | |
3994 | tvin_cutwin_t CTv::Tv_FactoryGetOverscan ( int source_type, int fmt, int status_3d, int trans_fmt ) |
3995 | { |
3996 | status_3d = status_3d; |
3997 | return mVpp.FactoryGetOverscan(source_type, fmt, Check2Dor3D(m_mode_3d, (tvin_trans_fmt_t)trans_fmt), trans_fmt); |
3998 | #if 0 |
3999 | else { |
4000 | tvin_cutwin_t cutwin; |
4001 | int ret = 0; |
4002 | char tmp_buf[16]; |
4003 | tmp_buf[0] = 0; |
4004 | |
4005 | if ((ret |= cfg_get_one_item("vpp.overscan.dtv", ",", 0, tmp_buf)) == 0) { |
4006 | cutwin.vs = strtol(tmp_buf, NULL, 10); |
4007 | } |
4008 | if ((ret |= cfg_get_one_item("vpp.overscan.dtv", ",", 1, tmp_buf)) == 0) { |
4009 | cutwin.hs = strtol(tmp_buf, NULL, 10); |
4010 | } |
4011 | if ((ret |= cfg_get_one_item("vpp.overscan.dtv", ",", 2, tmp_buf)) == 0) { |
4012 | cutwin.ve = strtol(tmp_buf, NULL, 10); |
4013 | } |
4014 | if ((ret |= cfg_get_one_item("vpp.overscan.dtv", ",", 3, tmp_buf)) == 0) { |
4015 | cutwin.he = strtol(tmp_buf, NULL, 10); |
4016 | } |
4017 | LOGD("%s,%d: %d,%d,%d,%d", __FUNCTION__, __LINE__, ( int ) cutwin.vs, ( int ) cutwin.hs, ( int ) cutwin.ve, ( int ) cutwin.he); |
4018 | return cutwin; |
4019 | } |
4020 | #endif |
4021 | } |
4022 | |
4023 | int CTv::Tv_ReplacePqDb(const char *newFilePath) |
4024 | { |
4025 | return mVpp.getPqData()->replacePqDb(newFilePath); |
4026 | } |
4027 | |
4028 | int CTv::Tv_FactorySet_FBC_Brightness ( int value ) |
4029 | { |
4030 | //int temp_value = (255*value)/100; |
4031 | int temp_value = value; |
4032 | |
4033 | if (fbcIns != NULL) { |
4034 | fbcIns->cfbc_Set_Brightness(COMM_DEV_SERIAL, temp_value); |
4035 | return 0; |
4036 | } |
4037 | return -1; |
4038 | } |
4039 | |
4040 | int CTv::Tv_FactoryGet_FBC_Brightness ( void ) |
4041 | { |
4042 | int temp_value = 0; |
4043 | int data = 0; |
4044 | |
4045 | if (fbcIns != NULL) { |
4046 | fbcIns->cfbc_Get_Brightness(COMM_DEV_SERIAL, &temp_value); |
4047 | //data = (temp_value*100)/255; |
4048 | data = temp_value; |
4049 | return data; |
4050 | } |
4051 | return 0; |
4052 | } |
4053 | |
4054 | int CTv::Tv_FactorySet_FBC_Contrast ( int value ) |
4055 | { |
4056 | //int temp_value = (255*value)/100; |
4057 | int temp_value = value; |
4058 | |
4059 | if (fbcIns != NULL) { |
4060 | fbcIns->cfbc_Set_Contrast(COMM_DEV_SERIAL, temp_value); |
4061 | return 0; |
4062 | } |
4063 | return -1; |
4064 | } |
4065 | |
4066 | int CTv::Tv_FactoryGet_FBC_Contrast ( void ) |
4067 | { |
4068 | int temp_value = 0; |
4069 | int data = 0; |
4070 | |
4071 | if (fbcIns != NULL) { |
4072 | fbcIns->cfbc_Get_Contrast(COMM_DEV_SERIAL, &temp_value); |
4073 | //data = (temp_value*100)/255; |
4074 | data = temp_value; |
4075 | return data; |
4076 | } |
4077 | return 0; |
4078 | } |
4079 | |
4080 | int CTv::Tv_FactorySet_FBC_Saturation ( int value ) |
4081 | { |
4082 | //int temp_value = (255*value)/100; |
4083 | int temp_value = value; |
4084 | |
4085 | if (fbcIns != NULL) { |
4086 | fbcIns->cfbc_Set_Saturation(COMM_DEV_SERIAL, temp_value); |
4087 | return 0; |
4088 | } |
4089 | return -1; |
4090 | } |
4091 | |
4092 | int CTv::Tv_FactoryGet_FBC_Saturation ( void ) |
4093 | { |
4094 | int temp_value = 0; |
4095 | int data = 0; |
4096 | |
4097 | if (fbcIns != NULL) { |
4098 | fbcIns->cfbc_Get_Saturation(COMM_DEV_SERIAL, &temp_value); |
4099 | //data = (temp_value*100)/255; |
4100 | data = temp_value; |
4101 | return data; |
4102 | } |
4103 | return 0; |
4104 | } |
4105 | |
4106 | int CTv::Tv_FactorySet_FBC_HueColorTint ( int value ) |
4107 | { |
4108 | //int temp_value = (255*value)/100; |
4109 | int temp_value = value; |
4110 | |
4111 | if (fbcIns != NULL) { |
4112 | fbcIns->cfbc_Set_HueColorTint(COMM_DEV_SERIAL, temp_value); |
4113 | return 0; |
4114 | } |
4115 | return -1; |
4116 | } |
4117 | |
4118 | int CTv::Tv_FactoryGet_FBC_HueColorTint ( void ) |
4119 | { |
4120 | int temp_value = 0; |
4121 | int data = 0; |
4122 | |
4123 | if (fbcIns != NULL) { |
4124 | fbcIns->cfbc_Get_HueColorTint(COMM_DEV_SERIAL, &temp_value); |
4125 | //data = (temp_value*100)/255; |
4126 | data = temp_value; |
4127 | return data; |
4128 | } |
4129 | return 0; |
4130 | } |
4131 | |
4132 | int CTv::Tv_FactorySet_FBC_Backlight ( int value ) |
4133 | { |
4134 | int temp_value = value; |
4135 | if (fbcIns != NULL) { |
4136 | temp_value = temp_value * 255 / 100; |
4137 | fbcIns->cfbc_Set_Backlight(COMM_DEV_SERIAL, temp_value); |
4138 | return 0; |
4139 | } |
4140 | return -1; |
4141 | } |
4142 | |
4143 | int CTv::Tv_FactoryGet_FBC_Backlight ( void ) |
4144 | { |
4145 | int temp_value = 0; |
4146 | int data = 0; |
4147 | |
4148 | if (fbcIns != NULL) { |
4149 | fbcIns->cfbc_Get_Backlight(COMM_DEV_SERIAL, &temp_value); |
4150 | if (temp_value * 100 % 255 == 0) |
4151 | temp_value = temp_value * 100 / 255; |
4152 | else |
4153 | temp_value = temp_value * 100 / 255 + 1; |
4154 | data = temp_value; |
4155 | return data; |
4156 | } |
4157 | |
4158 | return 0; |
4159 | } |
4160 | |
4161 | int CTv::Tv_FactorySet_FBC_Auto_Backlight_OnOff( unsigned char status) |
4162 | { |
4163 | if (fbcIns != NULL) { |
4164 | return fbcIns->cfbc_Set_Auto_Backlight_OnOff(COMM_DEV_SERIAL, status); |
4165 | } |
4166 | |
4167 | return -1; |
4168 | } |
4169 | |
4170 | int CTv::Tv_FactoryGet_FBC_Auto_Backlight_OnOff( void ) |
4171 | { |
4172 | int temp_status = 0; |
4173 | |
4174 | if (fbcIns != NULL) { |
4175 | fbcIns->cfbc_Get_Auto_Backlight_OnOff(COMM_DEV_SERIAL, &temp_status); |
4176 | return temp_status; |
4177 | } |
4178 | return 0; |
4179 | } |
4180 | |
4181 | int CTv::Tv_FactorySet_FBC_ELEC_MODE( int value ) |
4182 | { |
4183 | if (fbcIns != NULL) { |
4184 | fbcIns->cfbc_Set_AUTO_ELEC_MODE(COMM_DEV_SERIAL, value); |
4185 | SSMSaveFBCELECmodeVal(value); |
4186 | return 0; |
4187 | } |
4188 | return -1; |
4189 | } |
4190 | |
4191 | int CTv::Tv_FactoryGet_FBC_ELEC_MODE( void ) |
4192 | { |
4193 | int val = 0; |
4194 | SSMReadFBCELECmodeVal(&val); |
4195 | return val; |
4196 | } |
4197 | |
4198 | int CTv::Tv_FactorySet_FBC_BACKLIGHT_N360( int value ) |
4199 | { |
4200 | SSMSaveFBCELECmodeVal(value); |
4201 | return -1; |
4202 | } |
4203 | |
4204 | int CTv::Tv_FactoryGet_FBC_BACKLIGHT_N360( void ) |
4205 | { |
4206 | int val = 0; |
4207 | SSMReadFBCELECmodeVal(&val); |
4208 | return val; |
4209 | } |
4210 | |
4211 | int CTv::Tv_FactorySet_FBC_Thermal_State( int value ) |
4212 | { |
4213 | if (fbcIns != NULL) { |
4214 | fbcIns->cfbc_Set_Thermal_state(COMM_DEV_SERIAL, value); |
4215 | return 0; |
4216 | } |
4217 | |
4218 | return -1; |
4219 | } |
4220 | |
4221 | int CTv::Tv_FactorySet_FBC_Picture_Mode ( int mode ) |
4222 | { |
4223 | if (fbcIns != NULL) { |
4224 | fbcIns->cfbc_Set_Picture_Mode(COMM_DEV_SERIAL, mode); |
4225 | return 0; |
4226 | } |
4227 | |
4228 | return -1; |
4229 | } |
4230 | |
4231 | int CTv::Tv_FactoryGet_FBC_Picture_Mode ( void ) |
4232 | { |
4233 | int mode = 0; |
4234 | |
4235 | if (fbcIns != NULL) { |
4236 | fbcIns->cfbc_Get_Picture_Mode(COMM_DEV_SERIAL, &mode); |
4237 | return mode; |
4238 | } |
4239 | return 0; |
4240 | } |
4241 | |
4242 | int CTv::Tv_FactorySet_FBC_Set_Test_Pattern ( int mode ) |
4243 | { |
4244 | if (fbcIns != NULL) { |
4245 | fbcIns->cfbc_Set_Test_Pattern(COMM_DEV_SERIAL, mode); |
4246 | return 0; |
4247 | } |
4248 | |
4249 | return -1; |
4250 | } |
4251 | |
4252 | int CTv::Tv_FactoryGet_FBC_Get_Test_Pattern ( void ) |
4253 | { |
4254 | int mode = 0; |
4255 | |
4256 | if (fbcIns != NULL) { |
4257 | fbcIns->cfbc_Get_Test_Pattern(COMM_DEV_SERIAL, &mode); |
4258 | return mode; |
4259 | } |
4260 | |
4261 | return 0; |
4262 | } |
4263 | |
4264 | int CTv::Tv_FactorySet_FBC_Gain_Red( int value ) |
4265 | { |
4266 | int temp_value = 0; |
4267 | |
4268 | //temp_value = (value*255)/2047; |
4269 | //value 0 ~ 2047 |
4270 | temp_value = value; |
4271 | |
4272 | if (fbcIns != NULL) { |
4273 | fbcIns->cfbc_Set_Gain_Red(COMM_DEV_SERIAL, temp_value); |
4274 | return 0; |
4275 | } |
4276 | |
4277 | return -1; |
4278 | } |
4279 | |
4280 | int CTv::Tv_FactoryGet_FBC_Gain_Red ( void ) |
4281 | { |
4282 | int temp_value = 0, value = 0; |
4283 | |
4284 | if (fbcIns != NULL) { |
4285 | fbcIns->cfbc_Get_Gain_Red(COMM_DEV_SERIAL, &temp_value); |
4286 | //value 0 ~ 2047 |
4287 | //value = (temp_value*2047)/255; |
4288 | value = temp_value; |
4289 | |
4290 | return value; |
4291 | } |
4292 | |
4293 | return 0; |
4294 | } |
4295 | |
4296 | int CTv::Tv_FactorySet_FBC_Gain_Green( int value ) |
4297 | { |
4298 | int temp_value = 0; |
4299 | |
4300 | //temp_value = (value*255)/2047; |
4301 | //value 0 ~ 2047 |
4302 | temp_value = value; |
4303 | |
4304 | if (fbcIns != NULL) { |
4305 | fbcIns->cfbc_Set_Gain_Green(COMM_DEV_SERIAL, temp_value); |
4306 | return 0; |
4307 | } |
4308 | |
4309 | return -1; |
4310 | } |
4311 | |
4312 | int CTv::Tv_FactoryGet_FBC_Gain_Green ( void ) |
4313 | { |
4314 | int temp_value = 0, value = 0; |
4315 | |
4316 | if (fbcIns != NULL) { |
4317 | fbcIns->cfbc_Get_Gain_Green(COMM_DEV_SERIAL, &temp_value); |
4318 | //value 0 ~ 2047 |
4319 | //value = (temp_value*2047)/255; |
4320 | value = temp_value; |
4321 | |
4322 | return value; |
4323 | } |
4324 | |
4325 | return 0; |
4326 | } |
4327 | |
4328 | int CTv::Tv_FactoryGet_FBC_VIDEO_MUTE ( void ) |
4329 | { |
4330 | if (fbcIns != NULL) { |
4331 | fbcIns->cfbc_Set_VMute(COMM_DEV_SERIAL, 1); |
4332 | } |
4333 | |
4334 | return 0; |
4335 | } |
4336 | |
4337 | int CTv::Tv_FactorySet_FBC_Gain_Blue( int value ) |
4338 | { |
4339 | int temp_value = 0; |
4340 | |
4341 | //temp_value = (value*255)/2047; |
4342 | //value 0 ~ 2047 |
4343 | temp_value = value; |
4344 | |
4345 | if (fbcIns != NULL) { |
4346 | fbcIns->cfbc_Set_Gain_Blue(COMM_DEV_SERIAL, temp_value); |
4347 | return 0; |
4348 | } |
4349 | |
4350 | return -1; |
4351 | } |
4352 | |
4353 | int CTv::Tv_FactoryGet_FBC_Gain_Blue ( void ) |
4354 | { |
4355 | int temp_value = 0, value = 0; |
4356 | |
4357 | if (fbcIns != NULL) { |
4358 | fbcIns->cfbc_Get_Gain_Blue(COMM_DEV_SERIAL, &temp_value); |
4359 | //value 0 ~ 2047 |
4360 | //value = (temp_value*2047)/255; |
4361 | value = temp_value; |
4362 | |
4363 | return value; |
4364 | } |
4365 | |
4366 | return 0; |
4367 | } |
4368 | |
4369 | int CTv::Tv_FactorySet_FBC_Offset_Red( int value ) |
4370 | { |
4371 | //value -1024~+1023 |
4372 | int temp_value = 0; |
4373 | |
4374 | //temp_value = (value+1024)*255/2047; |
4375 | temp_value = value; |
4376 | |
4377 | if (fbcIns != NULL) { |
4378 | fbcIns->cfbc_Set_Offset_Red(COMM_DEV_SERIAL, temp_value); |
4379 | return 0; |
4380 | } |
4381 | |
4382 | return -1; |
4383 | } |
4384 | |
4385 | int CTv::Tv_FactoryGet_FBC_Offset_Red ( void ) |
4386 | { |
4387 | int temp_value = 0, value = 0; |
4388 | |
4389 | if (fbcIns != NULL) { |
4390 | fbcIns->cfbc_Get_Offset_Red(COMM_DEV_SERIAL, &temp_value); |
4391 | //value -1024~+1023 |
4392 | //value = (temp_value*2047)/255 - 1024; |
4393 | value = temp_value; |
4394 | |
4395 | return value; |
4396 | } |
4397 | |
4398 | return 0; |
4399 | } |
4400 | |
4401 | int CTv::Tv_FactorySet_FBC_Offset_Green( int value ) |
4402 | { |
4403 | //value -1024~+1023 |
4404 | int temp_value = 0; |
4405 | |
4406 | //temp_value = (value+1024)*255/2047; |
4407 | temp_value = value; |
4408 | |
4409 | if (fbcIns != NULL) { |
4410 | fbcIns->cfbc_Set_Offset_Green(COMM_DEV_SERIAL, temp_value); |
4411 | return 0; |
4412 | } |
4413 | |
4414 | return -1; |
4415 | } |
4416 | |
4417 | int CTv::Tv_FactoryGet_FBC_Offset_Green ( void ) |
4418 | { |
4419 | int temp_value = 0, value = 0; |
4420 | |
4421 | if (fbcIns != NULL) { |
4422 | fbcIns->cfbc_Get_Offset_Green(COMM_DEV_SERIAL, &temp_value); |
4423 | //value -1024~+1023 |
4424 | //value = (temp_value*2047)/255 - 1024; |
4425 | value = temp_value; |
4426 | |
4427 | return value; |
4428 | } |
4429 | |
4430 | return 0; |
4431 | } |
4432 | |
4433 | int CTv::Tv_FactorySet_FBC_Offset_Blue( int value ) |
4434 | { |
4435 | //value -1024~+1023 |
4436 | int temp_value = 0; |
4437 | |
4438 | //temp_value = (value+1024)*255/2047; |
4439 | temp_value = value; |
4440 | |
4441 | if (fbcIns != NULL) { |
4442 | fbcIns->cfbc_Set_Offset_Blue(COMM_DEV_SERIAL, value); |
4443 | return 0; |
4444 | } |
4445 | |
4446 | return -1; |
4447 | } |
4448 | |
4449 | int CTv::Tv_FactoryGet_FBC_Offset_Blue ( void ) |
4450 | { |
4451 | int temp_value = 0, value = 0; |
4452 | |
4453 | if (fbcIns != NULL) { |
4454 | fbcIns->cfbc_Get_Offset_Blue(COMM_DEV_SERIAL, &temp_value); |
4455 | //value -1024~+1023 |
4456 | //value = (temp_value*2047)/255 - 1024; |
4457 | value = temp_value; |
4458 | |
4459 | return value; |
4460 | } |
4461 | |
4462 | return 0; |
4463 | } |
4464 | |
4465 | int CTv::Tv_FactoryGetWhiteBalanceRedGain(int source_type, int colortemp_mode) |
4466 | { |
4467 | int ret = -1; |
4468 | if (!mHdmiOutFbc) { // not use fbc store the white balance params |
4469 | LOGD("--------- call none fbc method ---------"); |
4470 | ret = mVpp.FactoryGetColorTemp_Rgain(source_type, colortemp_mode); |
4471 | } else { //use fbc store the white balance params |
4472 | LOGD("--------- call fbc method ---------"); |
4473 | ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 0); |
4474 | } |
4475 | return ret; |
4476 | } |
4477 | |
4478 | int CTv::Tv_FactoryGetWhiteBalanceGreenGain(int source_type, int colortemp_mode) |
4479 | { |
4480 | int ret = -1; |
4481 | if (!mHdmiOutFbc) { // not use fbc store the white balance params |
4482 | ret = mVpp.FactoryGetColorTemp_Ggain(source_type, colortemp_mode); |
4483 | } else { //use fbc store the white balance params |
4484 | ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 1); |
4485 | } |
4486 | return ret; |
4487 | } |
4488 | |
4489 | int CTv::Tv_FactoryGetWhiteBalanceBlueGain(int source_type, int colortemp_mode) |
4490 | { |
4491 | int ret = -1; |
4492 | if (!mHdmiOutFbc) { // not use fbc store the white balance params |
4493 | ret = mVpp.FactoryGetColorTemp_Bgain(source_type, colortemp_mode); |
4494 | } else { //use fbc store the white balance params |
4495 | ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 2); |
4496 | } |
4497 | return ret; |
4498 | } |
4499 | |
4500 | int CTv::Tv_FactoryGetWhiteBalanceRedOffset(int source_type, int colortemp_mode) |
4501 | { |
4502 | int ret = -1; |
4503 | if (!mHdmiOutFbc) { // not use fbc store the white balance params |
4504 | ret = mVpp.FactoryGetColorTemp_Roffset(source_type, colortemp_mode); |
4505 | } else { //use fbc store the white balance params |
4506 | ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 3); |
4507 | } |
4508 | return ret; |
4509 | } |
4510 | |
4511 | int CTv::Tv_FactoryGetWhiteBalanceGreenOffset(int source_type, int colortemp_mode) |
4512 | { |
4513 | int ret = -1; |
4514 | if (!mHdmiOutFbc) { // not use fbc store the white balance params |
4515 | ret = mVpp.FactoryGetColorTemp_Goffset(source_type, colortemp_mode); |
4516 | } else { //use fbc store the white balance params |
4517 | ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 4); |
4518 | } |
4519 | return ret; |
4520 | } |
4521 | |
4522 | int CTv::Tv_FactoryGetWhiteBalanceBlueOffset(int source_type, int colortemp_mode) |
4523 | { |
4524 | int ret = -1; |
4525 | if (!mHdmiOutFbc) { // not use fbc store the white balance params |
4526 | ret = mVpp.FactoryGetColorTemp_Boffset(source_type, colortemp_mode); |
4527 | } else { //use fbc store the white balance params |
4528 | ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 5); |
4529 | } |
4530 | return ret; |
4531 | } |
4532 | |
4533 | int CTv::Tv_FactorySetWhiteBalanceRedGain(int source_type, int colortemp_mode, int value) |
4534 | { |
4535 | int ret = -1; |
4536 | if (value < 0) { |
4537 | value = 0; |
4538 | } else if (value > 2047) { |
4539 | value = 2047; |
4540 | } |
4541 | if (!mHdmiOutFbc) { // not use fbc store the white balance params |
4542 | ret = mVpp.FactorySetColorTemp_Rgain(source_type, colortemp_mode, value); |
4543 | if (ret != -1) { |
4544 | LOGD("save the red gain to flash") |
4545 | ret = mVpp.FactorySaveColorTemp_Rgain(source_type, colortemp_mode, value); |
4546 | } |
4547 | } else { //use fbc store the white balance params |
4548 | value = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(value); |
4549 | ret = Tv_FactorySet_FBC_Gain_Red(value); |
4550 | } |
4551 | return ret; |
4552 | } |
4553 | |
4554 | int CTv::Tv_FactorySetWhiteBalanceGreenGain(int source_type, int colortemp_mode, int value) |
4555 | { |
4556 | int ret = -1; |
4557 | if (value < 0) { |
4558 | value = 0; |
4559 | } else if (value > 2047) { |
4560 | value = 2047; |
4561 | } |
4562 | if (!mHdmiOutFbc) { // not use fbc store the white balance params |
4563 | ret = mVpp.FactorySetColorTemp_Ggain(source_type, colortemp_mode, value); |
4564 | if (ret != -1) { |
4565 | LOGD("save the green gain to flash") |
4566 | ret = mVpp.FactorySaveColorTemp_Ggain(source_type, colortemp_mode, value); |
4567 | } |
4568 | } else { //use fbc store the white balance params |
4569 | value = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(value); |
4570 | ret = Tv_FactorySet_FBC_Gain_Green(value); |
4571 | } |
4572 | return ret; |
4573 | } |
4574 | |
4575 | int CTv::Tv_FactorySetWhiteBalanceBlueGain(int source_type, int colortemp_mode, int value) |
4576 | { |
4577 | int ret = -1; |
4578 | if (value < 0) { |
4579 | value = 0; |
4580 | } else if (value > 2047) { |
4581 | value = 2047; |
4582 | } |
4583 | if (!mHdmiOutFbc) { // not use fbc store the white balance params |
4584 | ret = mVpp.FactorySetColorTemp_Bgain(source_type, colortemp_mode, value); |
4585 | if (ret != -1) { |
4586 | LOGD("save the blue gain to flash") |
4587 | ret = mVpp.FactorySaveColorTemp_Bgain(source_type, colortemp_mode, value); |
4588 | } |
4589 | } else { //use fbc store the white balance params |
4590 | value = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(value); |
4591 | ret = Tv_FactorySet_FBC_Gain_Blue(value); |
4592 | } |
4593 | return ret; |
4594 | } |
4595 | |
4596 | int CTv::Tv_FactorySetWhiteBalanceRedOffset(int source_type, int colortemp_mode, int value) |
4597 | { |
4598 | int ret = -1; |
4599 | if (value < -1024) { |
4600 | value = -1024; |
4601 | } else if (value > 1023) { |
4602 | value = 1023; |
4603 | } |
4604 | if (!mHdmiOutFbc) { // not use fbc store the white balance params |
4605 | ret = mVpp.FactorySetColorTemp_Roffset(source_type, colortemp_mode, value); |
4606 | if (ret != -1) { |
4607 | LOGD("save the red offset to flash") |
4608 | ret = mVpp.FactorySaveColorTemp_Roffset(source_type, colortemp_mode, value); |
4609 | } |
4610 | } else { //use fbc store the white balance params |
4611 | value = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(value); |
4612 | ret = Tv_FactorySet_FBC_Offset_Red(value); |
4613 | } |
4614 | return ret; |
4615 | } |
4616 | |
4617 | int CTv::Tv_FactorySetWhiteBalanceGreenOffset(int source_type, int colortemp_mode, int value) |
4618 | { |
4619 | int ret = -1; |
4620 | if (value < -1024) { |
4621 | value = -1024; |
4622 | } else if (value > 1023) { |
4623 | value = 1023; |
4624 | } |
4625 | if (!mHdmiOutFbc) { // not use fbc store the white balance params |
4626 | ret = mVpp.FactorySetColorTemp_Goffset(source_type, colortemp_mode, value); |
4627 | if (ret != -1) { |
4628 | LOGD("save the green offset to flash") |
4629 | ret = mVpp.FactorySaveColorTemp_Goffset(source_type, colortemp_mode, value); |
4630 | } |
4631 | } else { //use fbc store the white balance params |
4632 | value = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(value); |
4633 | ret = Tv_FactorySet_FBC_Offset_Green(value); |
4634 | } |
4635 | return ret; |
4636 | } |
4637 | |
4638 | int CTv::Tv_FactorySetWhiteBalanceBlueOffset(int source_type, int colortemp_mode, int value) |
4639 | { |
4640 | int ret = -1; |
4641 | if (value < -1024) { |
4642 | value = -1024; |
4643 | } else if (value > 1023) { |
4644 | value = 1023; |
4645 | } |
4646 | if (!mHdmiOutFbc) { // not use fbc store the white balance params |
4647 | ret = mVpp.FactorySetColorTemp_Boffset(source_type, colortemp_mode, value); |
4648 | if (ret != -1) { |
4649 | LOGD("save the blue offset to flash") |
4650 | ret = mVpp.FactorySaveColorTemp_Boffset(source_type, colortemp_mode, value); |
4651 | } |
4652 | } else { //use fbc store the white balance params |
4653 | value = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(value); |
4654 | ret = Tv_FactorySet_FBC_Offset_Blue(value); |
4655 | } |
4656 | return ret; |
4657 | } |
4658 | |
4659 | int CTv::Tv_FactorySetWhiteBalanceColorTempMode(int source_type, int colortemp_mode, int is_save) |
4660 | { |
4661 | int ret = -1; |
4662 | if (!mHdmiOutFbc) { // not use fbc store the white balance params |
4663 | ret = mVpp.SetColorTemperature((vpp_color_temperature_mode_t)colortemp_mode, (tv_source_input_type_t)source_type, is_save); |
4664 | } else { //use fbc store the white balance params |
4665 | ret = Tv_FactorySet_FBC_ColorTemp_Mode(colortemp_mode); |
4666 | } |
4667 | return ret; |
4668 | } |
4669 | |
4670 | int CTv::Tv_FactoryGetWhiteBalanceColorTempMode(int source_type ) |
4671 | { |
4672 | int ret = -1; |
4673 | if (!mHdmiOutFbc) { // not use fbc store the white balance params |
4674 | ret = mVpp.GetColorTemperature((tv_source_input_type_t)source_type); |
4675 | } else { //use fbc store the white balance params |
4676 | ret = Tv_FactoryGet_FBC_ColorTemp_Mode(); |
4677 | } |
4678 | return ret; |
4679 | } |
4680 | |
4681 | int CTv::Tv_FactoryWhiteBalanceFormatInputFbcGainParams(int value) |
4682 | { |
4683 | int ret = 1024; |
4684 | if (value < 0) { |
4685 | ret = 0; |
4686 | } else if (value > 2047) { |
4687 | ret = 2047; |
4688 | } else { |
4689 | ret = value; |
4690 | } |
4691 | ret = ret >> 3; |
4692 | return ret; |
4693 | } |
4694 | |
4695 | int CTv::Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(int value) |
4696 | { |
4697 | int ret = 0; |
4698 | if (value < -1024) { |
4699 | ret = -1024; |
4700 | } else if (value > 1023) { |
4701 | ret = 1023; |
4702 | } else { |
4703 | ret = value; |
4704 | } |
4705 | ret += 1024; |
4706 | ret = ret >> 3; |
4707 | return ret; |
4708 | } |
4709 | |
4710 | int CTv::Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(int value) |
4711 | { |
4712 | if (value == 255) { |
4713 | value = 1023; |
4714 | } else { |
4715 | value = value << 3; |
4716 | value -= 1024; |
4717 | } |
4718 | return value; |
4719 | } |
4720 | |
4721 | int CTv::Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(int value) |
4722 | { |
4723 | value = value << 3; |
4724 | if (value < 0) { |
4725 | value = 0; |
4726 | } else if (value > 2047) { |
4727 | value = 2047; |
4728 | } |
4729 | return value; |
4730 | } |
4731 | |
4732 | int 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) |
4733 | { |
4734 | int ret = 0; |
4735 | if (!mHdmiOutFbc) { // not use fbc store the white balance params |
4736 | mVpp.SaveColorTemp((vpp_color_temperature_mode_t) tempmode, (tv_source_input_type_t) source_type); |
4737 | mVpp.FactorySaveColorTemp_Rgain(source_type, tempmode, r_gain); |
4738 | mVpp.FactorySaveColorTemp_Ggain(source_type, tempmode, g_gain); |
4739 | mVpp.FactorySaveColorTemp_Bgain(source_type, tempmode, b_gain); |
4740 | mVpp.FactorySaveColorTemp_Roffset(source_type, tempmode, r_offset); |
4741 | mVpp.FactorySaveColorTemp_Goffset(source_type, tempmode, g_offset); |
4742 | mVpp.FactorySaveColorTemp_Boffset(source_type, tempmode, b_offset); |
4743 | } else { //use fbc store the white balance params |
4744 | tcon_rgb_ogo_t params; |
4745 | |
4746 | params.r_gain = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(r_gain); |
4747 | params.g_gain = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(g_gain); |
4748 | params.b_gain = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(b_gain); |
4749 | params.r_post_offset = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(r_offset); |
4750 | params.g_post_offset = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(g_offset); |
4751 | params.b_post_offset = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(b_offset); |
4752 | ret = Tv_FactorySet_FBC_ColorTemp_Batch((vpp_color_temperature_mode_t)tempmode, params); |
4753 | } |
4754 | return ret; |
4755 | } |
4756 | |
4757 | /** |
4758 | * The color temperature enum order is diffrent bettewn G9 and Fbc, so we have to make a mapping |
4759 | **/ |
4760 | int CTv::Tv_FactoryWhiteBalanceColorTempMappingG92Fbc(int Tempmode) |
4761 | { |
4762 | int ret = Tempmode; |
4763 | switch (Tempmode) { |
4764 | case 0: //standard |
4765 | ret = 1; |
4766 | break; |
4767 | case 1: //warm |
4768 | ret = 2; |
4769 | break; |
4770 | case 2: //cold |
4771 | ret = 0; |
4772 | break; |
4773 | default: |
4774 | break; |
4775 | } |
4776 | return ret; |
4777 | } |
4778 | |
4779 | /** |
4780 | * The color temperature enum order is diffrent bettewn G9 and Fbc, so we have to make a mapping |
4781 | **/ |
4782 | int CTv::Tv_FactoryWhiteBalanceColorTempMappingFbc2G9(int Tempmode) |
4783 | { |
4784 | int ret = Tempmode; |
4785 | switch (Tempmode) { |
4786 | case 0: //cold |
4787 | ret = 2; |
4788 | break; |
4789 | case 1: //standard |
4790 | ret = 0; |
4791 | break; |
4792 | case 2: //warm |
4793 | ret = 1; |
4794 | break; |
4795 | default: |
4796 | break; |
4797 | } |
4798 | return ret; |
4799 | } |
4800 | |
4801 | int CTv::Tv_SetTestPattern(int value) |
4802 | { |
4803 | int ret = -1; |
4804 | if (fbcIns != NULL) { |
4805 | LOGD("%s, value is %d\n", __FUNCTION__, value); |
4806 | ret = fbcIns->cfbc_TestPattern_Select(COMM_DEV_SERIAL, value); |
4807 | } |
4808 | |
4809 | return ret; |
4810 | } |
4811 | |
4812 | int CTv::Tv_FactoryCloseWhiteBalanceGrayPattern() |
4813 | { |
4814 | int useFbc = 0; |
4815 | int ret = -1; |
4816 | if (!mHdmiOutFbc) { // not use fbc store the white balance params |
4817 | ret = mVpp.VPP_SetGrayPattern(0); |
4818 | } else { //use fbc store the white balance params |
4819 | ret = Tv_FactoryClose_FBC_GrayPattern(); |
4820 | } |
4821 | return ret; |
4822 | } |
4823 | |
4824 | int CTv::Tv_FactoryOpenWhiteBalanceGrayPattern() |
4825 | { |
4826 | int ret = 0; |
4827 | if (mHdmiOutFbc) { //use fbc store the white balance params |
4828 | ret = Tv_FactoryOpen_FBC_GrayPattern(); |
4829 | } |
4830 | return ret; |
4831 | } |
4832 | |
4833 | int CTv::Tv_FactorySetWhiteBalanceGrayPattern(int value) |
4834 | { |
4835 | int ret = -1; |
4836 | if (!mHdmiOutFbc) { |
4837 | ret = mVpp.VPP_SetGrayPattern(value); |
4838 | } else { |
4839 | ret = Tv_FactorySet_FBC_GrayPattern(value); |
4840 | } |
4841 | return ret; |
4842 | } |
4843 | |
4844 | int CTv:: Tv_FactoryGetWhiteBalanceGrayPattern() |
4845 | { |
4846 | int ret = -1; |
4847 | if (!mHdmiOutFbc) { |
4848 | ret = mVpp.VPP_GetGrayPattern(); |
4849 | } |
4850 | return ret; |
4851 | } |
4852 | |
4853 | int CTv::Tv_FactorySet_FBC_GrayPattern(int value) |
4854 | { |
4855 | int ret = -1; |
4856 | unsigned char grayValue = 0; |
4857 | if (value > 255) { |
4858 | grayValue = 255; |
4859 | } else if (value < 0) { |
4860 | grayValue = 0; |
4861 | } else { |
4862 | grayValue = (unsigned char)(0xFF & value); |
4863 | } |
4864 | if (fbcIns != NULL) { |
4865 | ret = fbcIns->cfbc_WhiteBalance_SetGrayPattern(COMM_DEV_SERIAL, grayValue); |
4866 | } |
4867 | return ret; |
4868 | } |
4869 | |
4870 | int CTv::Tv_FactoryOpen_FBC_GrayPattern() |
4871 | { |
4872 | int ret = -1; |
4873 | if (fbcIns != NULL) { |
4874 | ret = fbcIns->cfbc_WhiteBalance_GrayPattern_OnOff(COMM_DEV_SERIAL, 0); |
4875 | } |
4876 | return ret; |
4877 | } |
4878 | |
4879 | int CTv::Tv_FactoryClose_FBC_GrayPattern() |
4880 | { |
4881 | int ret = -1; |
4882 | if (fbcIns != NULL) { |
4883 | ret = fbcIns->cfbc_WhiteBalance_GrayPattern_OnOff(COMM_DEV_SERIAL, 1); |
4884 | } |
4885 | return ret; |
4886 | } |
4887 | |
4888 | int CTv::Tv_FactorySet_FBC_ColorTemp_Mode( int mode ) |
4889 | { |
4890 | if (fbcIns != NULL) { |
4891 | fbcIns->cfbc_Set_ColorTemp_Mode(COMM_DEV_SERIAL, mode); |
4892 | return 0; |
4893 | } |
4894 | |
4895 | return -1; |
4896 | } |
4897 | |
4898 | int CTv::Tv_FactoryGet_FBC_ColorTemp_Mode ( void ) |
4899 | { |
4900 | int temp_mode = 0; |
4901 | |
4902 | if (fbcIns != NULL) { |
4903 | fbcIns->cfbc_Get_ColorTemp_Mode(COMM_DEV_SERIAL, &temp_mode); |
4904 | return temp_mode; |
4905 | } |
4906 | |
4907 | return -1; |
4908 | } |
4909 | |
4910 | int CTv::Tv_FactorySet_FBC_ColorTemp_Mode_N360( int mode ) |
4911 | { |
4912 | if (fbcIns != NULL) { |
4913 | fbcIns->cfbc_Set_ColorTemp_Mode(COMM_DEV_SERIAL, mode); |
4914 | SSMSaveFBCN360ColorTempVal(mode); |
4915 | return 0; |
4916 | } |
4917 | |
4918 | return -1; |
4919 | } |
4920 | |
4921 | int CTv::Tv_FactoryGet_FBC_ColorTemp_Mode_N360 ( void ) |
4922 | { |
4923 | int temp_mode = 0; |
4924 | SSMReadFBCN360ColorTempVal(&temp_mode); |
4925 | return temp_mode; |
4926 | } |
4927 | |
4928 | int CTv::Tv_FactorySet_FBC_LockN_state(int value) |
4929 | { |
4930 | LOGE ("Tv_FactorySet_FBC_LockN_state %d!!!\n", value); |
4931 | if (fbcIns != NULL) { |
4932 | fbcIns->cfbc_Set_LockN_state(COMM_DEV_SERIAL, value); |
4933 | return 0; |
4934 | } |
4935 | return -1; |
4936 | } |
4937 | |
4938 | int CTv::Tv_FactorySet_FBC_WB_Initial( int status ) |
4939 | { |
4940 | if (fbcIns != NULL) { |
4941 | fbcIns->cfbc_Set_WB_Initial(COMM_DEV_SERIAL, status); |
4942 | return 0; |
4943 | } |
4944 | |
4945 | return -1; |
4946 | } |
4947 | |
4948 | int CTv::Tv_FactoryGet_FBC_WB_Initial ( void ) |
4949 | { |
4950 | int temp_status = 0; |
4951 | |
4952 | if (fbcIns != NULL) { |
4953 | fbcIns->cfbc_Get_WB_Initial(COMM_DEV_SERIAL, &temp_status); |
4954 | return temp_status; |
4955 | } |
4956 | |
4957 | return 0; |
4958 | } |
4959 | |
4960 | int CTv::Tv_FactorySet_FBC_ColorTemp_Batch(vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t params) |
4961 | { |
4962 | unsigned char mode = 0, r_gain, g_gain, b_gain, r_offset, g_offset, b_offset; |
4963 | switch (Tempmode) { |
4964 | case VPP_COLOR_TEMPERATURE_MODE_STANDARD: |
4965 | mode = 1; //COLOR_TEMP_STD |
4966 | break; |
4967 | case VPP_COLOR_TEMPERATURE_MODE_WARM: |
4968 | mode = 2; //COLOR_TEMP_WARM |
4969 | break; |
4970 | case VPP_COLOR_TEMPERATURE_MODE_COLD: |
4971 | mode = 0; //COLOR_TEMP_COLD |
4972 | break; |
4973 | case VPP_COLOR_TEMPERATURE_MODE_USER: |
4974 | mode = 3; //COLOR_TEMP_USER |
4975 | break; |
4976 | default: |
4977 | break; |
4978 | } |
4979 | r_gain = (params.r_gain * 255) / 2047; // u1.10, range 0~2047, default is 1024 (1.0x) |
4980 | g_gain = (params.g_gain * 255) / 2047; |
4981 | b_gain = (params.b_gain * 255) / 2047; |
4982 | r_offset = (params.r_post_offset + 1024) * 255 / 2047; // s11.0, range -1024~+1023, default is 0 |
4983 | g_offset = (params.g_post_offset + 1024) * 255 / 2047; |
4984 | b_offset = (params.b_post_offset + 1024) * 255 / 2047; |
4985 | LOGD ( "~Tv_FactorySet_FBC_ColorTemp_Batch##%d,%d,%d,%d,%d,%d,##", r_gain, g_gain, b_gain, r_offset, g_offset, b_offset ); |
4986 | |
4987 | if (fbcIns != NULL) { |
4988 | fbcIns->cfbc_Set_WB_Batch(COMM_DEV_SERIAL, mode, r_gain, g_gain, b_gain, r_offset, g_offset, b_offset); |
4989 | return 0; |
4990 | } |
4991 | |
4992 | return -1; |
4993 | } |
4994 | |
4995 | int CTv::Tv_FactoryGet_FBC_ColorTemp_Batch ( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params ) |
4996 | { |
4997 | unsigned char mode = 0, r_gain, g_gain, b_gain, r_offset, g_offset, b_offset; |
4998 | switch (Tempmode) { |
4999 | case VPP_COLOR_TEMPERATURE_MODE_STANDARD: |
5000 | mode = 1; //COLOR_TEMP_STD |
5001 | break; |
5002 | case VPP_COLOR_TEMPERATURE_MODE_WARM: |
5003 | mode = 2; //COLOR_TEMP_WARM |
5004 | break; |
5005 | case VPP_COLOR_TEMPERATURE_MODE_COLD: |
5006 | mode = 0; //COLOR_TEMP_COLD |
5007 | break; |
5008 | case VPP_COLOR_TEMPERATURE_MODE_USER: |
5009 | mode = 3; //COLOR_TEMP_USER |
5010 | break; |
5011 | default: |
5012 | break; |
5013 | } |
5014 | |
5015 | if (fbcIns != NULL) { |
5016 | fbcIns->cfbc_Get_WB_Batch(COMM_DEV_SERIAL, mode, &r_gain, &g_gain, &b_gain, &r_offset, &g_offset, &b_offset); |
5017 | LOGD ( "~Tv_FactoryGet_FBC_ColorTemp_Batch##%d,%d,%d,%d,%d,%d,##", r_gain, g_gain, b_gain, r_offset, g_offset, b_offset ); |
5018 | |
5019 | params->r_gain = (r_gain * 2047) / 255; |
5020 | params->g_gain = (g_gain * 2047) / 255; |
5021 | params->b_gain = (b_gain * 2047) / 255; |
5022 | params->r_post_offset = (r_offset * 2047) / 255 - 1024; |
5023 | params->g_post_offset = (g_offset * 2047) / 255 - 1024; |
5024 | params->b_post_offset = (b_offset * 2047) / 255 - 1024; |
5025 | return 0; |
5026 | } |
5027 | |
5028 | return -1; |
5029 | } |
5030 | |
5031 | int CTv::Tv_FactorySet_WB_G9_To_FBC( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t params ) |
5032 | { |
5033 | Tv_FactorySet_FBC_ColorTemp_Batch(Tempmode, params); |
5034 | return 0; |
5035 | } |
5036 | |
5037 | int CTv::Tv_FactoryGet_WB_G9_To_FBC ( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params ) |
5038 | { |
5039 | int temp_status = 0; |
5040 | Tv_FactoryGet_FBC_ColorTemp_Batch(Tempmode, params); |
5041 | return temp_status; |
5042 | } |
5043 | |
5044 | int CTv::Tv_FactoryGetItemFromBatch(vpp_color_temperature_mode_t colortemp_mode, int item) |
5045 | { |
5046 | tcon_rgb_ogo_t params; |
5047 | int ret = 0; |
5048 | |
5049 | Tv_FactoryGet_FBC_ColorTemp_Batch((vpp_color_temperature_mode_t)colortemp_mode, ¶ms); |
5050 | switch (item) { |
5051 | case 0: |
5052 | ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params.r_gain); |
5053 | break; |
5054 | case 1: |
5055 | ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params.g_gain); |
5056 | break; |
5057 | case 2: |
5058 | ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params.b_gain); |
5059 | break; |
5060 | case 3: |
5061 | ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params.r_post_offset); |
5062 | break; |
5063 | case 4: |
5064 | ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params.g_post_offset); |
5065 | break; |
5066 | case 5: |
5067 | ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params.b_post_offset); |
5068 | break; |
5069 | default: |
5070 | ret = 0; |
5071 | } |
5072 | return ret; |
5073 | } |
5074 | |
5075 | int CTv::Tv_FactorySet_FBC_CM_OnOff( unsigned char status ) |
5076 | { |
5077 | if (fbcIns != NULL) { |
5078 | fbcIns->cfbc_Set_CM(COMM_DEV_SERIAL, status); |
5079 | return 0; |
5080 | } |
5081 | |
5082 | return -1; |
5083 | } |
5084 | |
5085 | int CTv::Tv_FactoryGet_FBC_CM_OnOff (void) |
5086 | { |
5087 | int temp_status = 0; |
5088 | |
5089 | if (fbcIns != NULL) { |
5090 | fbcIns->cfbc_Get_CM(COMM_DEV_SERIAL, &temp_status); |
5091 | return temp_status; |
5092 | } |
5093 | |
5094 | return 0; |
5095 | } |
5096 | |
5097 | int CTv::Tv_FactorySet_FBC_DNLP_OnOff( unsigned char status ) |
5098 | { |
5099 | if (fbcIns != NULL) { |
5100 | fbcIns->cfbc_Set_DNLP(COMM_DEV_SERIAL, status); |
5101 | return 0; |
5102 | } |
5103 | |
5104 | return -1; |
5105 | } |
5106 | |
5107 | int CTv::Tv_FactoryGet_FBC_DNLP_OnOff (void) |
5108 | { |
5109 | int temp_status = 0; |
5110 | |
5111 | if (fbcIns != NULL) { |
5112 | fbcIns->cfbc_Get_DNLP(COMM_DEV_SERIAL, &temp_status); |
5113 | return temp_status; |
5114 | } |
5115 | |
5116 | return 0; |
5117 | } |
5118 | |
5119 | int CTv::Tv_FactorySet_FBC_Gamma_OnOff( unsigned char status ) |
5120 | { |
5121 | if (fbcIns != NULL) { |
5122 | fbcIns->cfbc_Set_Gamma(COMM_DEV_SERIAL, status); |
5123 | return 0; |
5124 | } |
5125 | |
5126 | return -1; |
5127 | } |
5128 | |
5129 | int CTv::Tv_FactoryGet_FBC_Gamma_OnOff (void) |
5130 | { |
5131 | int temp_status = 0; |
5132 | |
5133 | if (fbcIns != NULL) { |
5134 | fbcIns->cfbc_Get_Gamma(COMM_DEV_SERIAL, &temp_status); |
5135 | return temp_status; |
5136 | } |
5137 | |
5138 | return 0; |
5139 | } |
5140 | |
5141 | int CTv::Tv_FactorySet_FBC_WhiteBalance_OnOff( unsigned char status ) |
5142 | { |
5143 | if (fbcIns != NULL) { |
5144 | fbcIns->cfbc_Set_WhiteBalance_OnOff(COMM_DEV_SERIAL, status); |
5145 | return 0; |
5146 | } |
5147 | |
5148 | return -1; |
5149 | } |
5150 | |
5151 | int CTv::Tv_FactoryGet_FBC_WhiteBalance_OnOff (void) |
5152 | { |
5153 | int temp_status = 0; |
5154 | |
5155 | if (fbcIns != NULL) { |
5156 | fbcIns->cfbc_Get_WhiteBalance_OnOff(COMM_DEV_SERIAL, &temp_status); |
5157 | return temp_status; |
5158 | } |
5159 | |
5160 | return 0; |
5161 | } |
5162 | |
5163 | int CTv::Tv_FactorySet_FBC_backlight_onoff ( int value ) |
5164 | { |
5165 | if (fbcIns != NULL) { |
5166 | fbcIns->cfbc_Set_backlight_onoff(COMM_DEV_SERIAL, value); |
5167 | return 0; |
5168 | } |
5169 | |
5170 | return -1; |
5171 | } |
5172 | |
5173 | int CTv::Tv_FactoryGet_FBC_backlight_onoff ( void ) |
5174 | { |
5175 | int temp_value = 0; |
5176 | |
5177 | if (fbcIns != NULL) { |
5178 | fbcIns->cfbc_Get_backlight_onoff(COMM_DEV_SERIAL, &temp_value); |
5179 | return temp_value; |
5180 | } |
5181 | |
5182 | return 0; |
5183 | } |
5184 | |
5185 | int CTv::Tv_FactorySet_FBC_LVDS_SSG_Set( int value ) |
5186 | { |
5187 | if (fbcIns != NULL) { |
5188 | fbcIns->cfbc_Set_LVDS_SSG_Set(COMM_DEV_SERIAL, value); |
5189 | return 0; |
5190 | } |
5191 | |
5192 | return -1; |
5193 | } |
5194 | |
5195 | int CTv::Tv_FactorySet_FBC_LightSensor_Status_N310 ( int value ) |
5196 | { |
5197 | if (fbcIns != NULL) { |
5198 | fbcIns->cfbc_Set_LightSensor_N310(COMM_DEV_SERIAL, value); |
5199 | SSMSaveFBCN310LightsensorVal(value); |
5200 | return 0; |
5201 | } |
5202 | |
5203 | return -1; |
5204 | } |
5205 | |
5206 | int CTv::Tv_FactoryGet_FBC_LightSensor_Status_N310 ( void ) |
5207 | { |
5208 | int data = 0; |
5209 | if (fbcIns != NULL) { |
5210 | SSMReadFBCN310LightsensorVal(&data); |
5211 | return data; |
5212 | } |
5213 | |
5214 | return 0; |
5215 | } |
5216 | |
5217 | int CTv::Tv_FactorySet_FBC_Dream_Panel_Status_N310 ( int value ) |
5218 | { |
5219 | if (fbcIns != NULL) { |
5220 | fbcIns->cfbc_Set_Dream_Panel_N310(COMM_DEV_SERIAL, value); |
5221 | SSMSaveFBCN310Dream_PanelVal(value); |
5222 | return 0; |
5223 | } |
5224 | |
5225 | return -1; |
5226 | } |
5227 | |
5228 | int CTv::Tv_FactoryGet_FBC_Dream_Panel_Status_N310 ( void ) |
5229 | { |
5230 | int data = 0; |
5231 | if (fbcIns != NULL) { |
5232 | SSMReadFBCN310Dream_PanelVal(&data); |
5233 | return data; |
5234 | } |
5235 | |
5236 | return 0; |
5237 | } |
5238 | |
5239 | int CTv::Tv_FactorySet_FBC_MULT_PQ_Status_N310 ( int value ) |
5240 | { |
5241 | if (fbcIns != NULL) { |
5242 | fbcIns->cfbc_Set_MULT_PQ_N310(COMM_DEV_SERIAL, value); |
5243 | SSMSaveFBCN310MULT_PQVal(value); |
5244 | return 0; |
5245 | } |
5246 | |
5247 | return -1; |
5248 | } |
5249 | |
5250 | int CTv::Tv_FactoryGet_FBC_MULT_PQ_Status_N310 ( void ) |
5251 | { |
5252 | int data = 0; |
5253 | |
5254 | if (fbcIns != NULL) { |
5255 | SSMReadFBCN310MULT_PQVal(&data); |
5256 | return data; |
5257 | } |
5258 | |
5259 | return 0; |
5260 | } |
5261 | |
5262 | int CTv::Tv_FactorySet_FBC_MEMC_Status_N310 ( int value ) |
5263 | { |
5264 | if (fbcIns != NULL) { |
5265 | fbcIns->cfbc_Set_MEMC_N310(COMM_DEV_SERIAL, value); |
5266 | SSMSaveFBCN310MEMCVal(value); |
5267 | return 0; |
5268 | } |
5269 | |
5270 | return -1; |
5271 | } |
5272 | |
5273 | int CTv::Tv_FactoryGet_FBC_MEMC_Status_N310 ( void ) |
5274 | { |
5275 | int data = 0; |
5276 | if (fbcIns != NULL) { |
5277 | SSMReadFBCN310MEMCVal(&data); |
5278 | return data; |
5279 | } |
5280 | |
5281 | return -1; |
5282 | } |
5283 | |
5284 | int CTv::Tv_FactorySet_FBC_ColorTemp_Mode_N310( int mode ) |
5285 | { |
5286 | //int colorTemp = 0; |
5287 | if (fbcIns != NULL) { |
5288 | //colorTemp = Tv_FactoryWhiteBalanceColorTempMappingG92Fbc(mode); |
5289 | fbcIns->cfbc_Set_ColorTemp_Mode(COMM_DEV_SERIAL, mode); |
5290 | SSMSaveFBCN310ColorTempVal(mode); |
5291 | return 0; |
5292 | } |
5293 | |
5294 | return -1; |
5295 | } |
5296 | |
5297 | int CTv::Tv_FactoryGet_FBC_ColorTemp_Mode_N310 ( void ) |
5298 | { |
5299 | int mode = 0; |
5300 | if (fbcIns != NULL) { |
5301 | SSMReadFBCN310ColorTempVal(&mode); |
5302 | //mode = Tv_FactoryWhiteBalanceColorTempMappingFbc2G9(temp_mode); |
5303 | |
5304 | return mode; |
5305 | } |
5306 | return -1; |
5307 | } |
5308 | |
5309 | int CTv::Tv_FactorySet_FBC_Backlight_N310 ( int value ) |
5310 | { |
5311 | if (fbcIns != NULL) { |
5312 | fbcIns->cfbc_Set_Backlight(COMM_DEV_SERIAL, value); |
5313 | SSMSaveFBCN310BackLightVal(value); |
5314 | return 0; |
5315 | } |
5316 | |
5317 | return -1; |
5318 | } |
5319 | |
5320 | int CTv::Tv_FactoryGet_FBC_Backlight_N310 ( void ) |
5321 | { |
5322 | int val = 0; |
5323 | |
5324 | if (fbcIns != NULL) { |
5325 | SSMReadFBCN310BackLightVal(&val); |
5326 | return val; |
5327 | } |
5328 | |
5329 | return -1; |
5330 | } |
5331 | |
5332 | int CTv::Tv_FactorySet_FBC_Bluetooth_IIS_N310 ( int value ) |
5333 | { |
5334 | if (fbcIns != NULL) { |
5335 | fbcIns->cfbc_Set_Bluetooth_IIS_onoff(COMM_DEV_SERIAL, value); |
5336 | return 0; |
5337 | } |
5338 | |
5339 | return -1; |
5340 | } |
5341 | |
5342 | int CTv::Tv_FactoryGet_FBC_Bluetooth_IIS_N310 ( void ) |
5343 | { |
5344 | int temp_value = 0; |
5345 | |
5346 | if (fbcIns != NULL) { |
5347 | fbcIns->cfbc_Get_Bluetooth_IIS_onoff(COMM_DEV_SERIAL, &temp_value); |
5348 | return temp_value; |
5349 | } |
5350 | |
5351 | return 0; |
5352 | } |
5353 | |
5354 | int CTv::Tv_FactorySet_FBC_Led_N310 ( int val_1, int val_2, int val_3 ) |
5355 | { |
5356 | int val = 0; |
5357 | |
5358 | if (fbcIns != NULL) { |
5359 | val = fbcIns->cfbc_Set_Led_onoff(COMM_DEV_SERIAL, val_1, val_2, val_3); |
5360 | return val; |
5361 | } |
5362 | |
5363 | return -1; |
5364 | } |
5365 | |
5366 | int CTv::Tv_FactorySet_VbyOne_Spread_Spectrum_N311 ( int value ) |
5367 | { |
5368 | if (fbcIns != NULL) { |
5369 | return -1; |
5370 | } else { |
5371 | LOGD("%s, Set spectrum for T868 V-by-one....%d....\n", __FUNCTION__ , value); |
5372 | SSMSaveN311_VbyOne_Spread_Spectrum_Val(value); |
5373 | |
5374 | switch (value) { |
5375 | case 0: |
5376 | //SetFileAttrValue ( "/sys/class/amlogic/debug" ,"w 0x135c5091 c 0x10ca"); |
5377 | //SetFileAttrValue ( "/sys/class/amlogic/debug" ,"w 0x801da72c c 0x10cb"); |
5378 | break; |
5379 | case 1: |
5380 | SetFileAttrValue ( "/sys/class/amlogic/debug" , "w 0x1ba05091 c 0x10ca"); |
5381 | SetFileAttrValue ( "/sys/class/amlogic/debug" , "w 0x80bda72c c 0x10cb"); |
5382 | break; |
5383 | default: |
5384 | LOGD("%s, Set spectrum for T868 V-by-one....%d....\n", __FUNCTION__ , value); |
5385 | break; |
5386 | } |
5387 | |
5388 | return 0; |
5389 | } |
5390 | } |
5391 | |
5392 | int CTv::Tv_FactoryGet_VbyOne_Spread_Spectrum_N311 ( void ) |
5393 | { |
5394 | int val = 0; |
5395 | if (fbcIns != NULL) { |
5396 | return -1; |
5397 | } else { |
5398 | SSMReadN311_VbyOne_Spread_Spectrum_Val(&val); |
5399 | return val; |
5400 | } |
5401 | } |
5402 | |
5403 | int CTv::Tv_FactorySet_FBC_AP_STANDBY_N310 ( int value ) |
5404 | { |
5405 | if (fbcIns != NULL) { |
5406 | fbcIns->cfbc_Set_AP_STANDBY_N310(COMM_DEV_SERIAL, value); |
5407 | return 0; |
5408 | } |
5409 | |
5410 | return -1; |
5411 | } |
5412 | |
5413 | int CTv::Tv_FactoryGet_FBC_AP_STANDBY_N310( void ) |
5414 | { |
5415 | int temp_value = 0; |
5416 | |
5417 | if (fbcIns != NULL) { |
5418 | fbcIns->cfbc_Get_AP_STANDBY_N310(COMM_DEV_SERIAL, &temp_value); |
5419 | return temp_value; |
5420 | } |
5421 | |
5422 | return 0; |
5423 | } |
5424 | |
5425 | int CTv::Tv_FactorySet_Uboot_Stage(int value) |
5426 | { |
5427 | if (fbcIns != NULL) { |
5428 | fbcIns->cfbc_Set_Fbc_Uboot_Stage(COMM_DEV_SERIAL, value); |
5429 | return 0; |
5430 | } |
5431 | |
5432 | return -1; |
5433 | } |
5434 | |
5435 | //audio |
5436 | void CTv::TvAudioOpen() |
5437 | { |
5438 | SetAudioAVOutMute(CC_AUDIO_UNMUTE); |
5439 | SetAudioSPDIFMute(CC_AUDIO_UNMUTE); |
5440 | project_info_t tmp_info; |
5441 | if (GetProjectInfo(&tmp_info) == 0) { |
5442 | strncpy(mMainVolLutTableExtraName, tmp_info.amp_curve_name, CC_PROJECT_INFO_ITEM_MAX_LEN - 1); |
5443 | } |
5444 | openTvAudio(); |
5445 | } |
5446 | |
5447 | void CTv::AudioCtlUninit() |
5448 | { |
5449 | int oldMuteStatus; |
5450 | |
5451 | oldMuteStatus = GetAudioMuteForTv(); |
5452 | SetAudioMuteForTv(CC_AUDIO_MUTE); |
5453 | |
5454 | //AudioCtlUninit(); |
5455 | AudioSetAudioInSource (CC_AUDIO_IN_SOURCE_HDMI); |
5456 | SetDAC_Digital_PlayBack_Volume(255); |
5457 | AudioSetAudioSourceType (AUDIO_MPEG_SOURCE); |
5458 | UnInitTvAudio(); |
5459 | SetAudioVolumeCompensationVal(0); |
5460 | SetAudioMasterVolume(GetAudioMasterVolume()); |
5461 | UnInitSetTvAudioCard(); |
5462 | |
5463 | SetAudioMuteForTv(oldMuteStatus); |
5464 | } |
5465 | |
5466 | char *CTv::GetMainVolLutTableExtraName() |
5467 | { |
5468 | return mMainVolLutTableExtraName; |
5469 | } |
5470 | |
5471 | //audio |
5472 | int CTv::SetAudioMuteForSystem(int muteOrUnmute) |
5473 | { |
5474 | int ret = 0; |
5475 | LOGD("SetAudioMuteForSystem sysMuteStats=%d, tvMuteStatus=%d, toMute=%d", mAudioMuteStatusForSystem, mAudioMuteStatusForTv, muteOrUnmute); |
5476 | mAudioMuteStatusForSystem = muteOrUnmute; |
5477 | ret |= SetDacMute(mAudioMuteStatusForSystem, CC_DAC_MUTE_TYPE_EXTERNAL); |
5478 | ret |= SetAudioI2sMute(mAudioMuteStatusForSystem | mAudioMuteStatusForTv); |
5479 | return ret; |
5480 | } |
5481 | |
5482 | int CTv::GetAudioMuteForSystem() |
5483 | { |
5484 | return mAudioMuteStatusForSystem; |
5485 | } |
5486 | |
5487 | int CTv::SetAudioMuteForTv(int muteOrUnmute) |
5488 | { |
5489 | int ret = 0; |
5490 | mAudioMuteStatusForTv = muteOrUnmute; |
5491 | LOGD("SetAudioMuteForTv sysMuteStats=%d, tvMuteStatus=%d, toMute=%d", mAudioMuteStatusForSystem, mAudioMuteStatusForTv, muteOrUnmute); |
5492 | ret |= SetDacMute(mAudioMuteStatusForSystem | mAudioMuteStatusForTv, CC_DAC_MUTE_TYPE_EXTERNAL | CC_DAC_MUTE_TYPE_INTERNAL); |
5493 | ret |= SetAudioI2sMute(mAudioMuteStatusForTv); |
5494 | return ret; |
5495 | } |
5496 | |
5497 | int CTv::GetAudioMuteForTv() |
5498 | { |
5499 | return mAudioMuteStatusForTv; |
5500 | } |
5501 | |
5502 | int CTv::GetDbxTvMode(int *mode, int *son_value, int *vol_value, int *sur_value) |
5503 | { |
5504 | *mode = 0; |
5505 | return SSMReadAudioDbxTvValue(son_value, vol_value, sur_value); |
5506 | } |
5507 | |
5508 | int CTv::SetAudioSPDIFSwitch(int tmp_val) |
5509 | { |
5510 | int muteStatus = CC_AUDIO_UNMUTE; |
5511 | |
5512 | SaveCurAudioSPDIFSwitch(tmp_val); |
5513 | |
5514 | if (tmp_val == CC_SWITCH_OFF /*|| mAudioMuteStatusForSystem == CC_AUDIO_MUTE || mAudioMuteStatusForTv == CC_AUDIO_MUTE*/) { |
5515 | muteStatus = CC_AUDIO_MUTE; |
5516 | } else { |
5517 | muteStatus = CC_AUDIO_UNMUTE; |
5518 | } |
5519 | |
5520 | SetAudioSPDIFMute(muteStatus); |
5521 | return 0; |
5522 | } |
5523 | |
5524 | int CTv::AudioHandleHeadsetPlugIn() |
5525 | { |
5526 | return 0; |
5527 | } |
5528 | |
5529 | int CTv::AudioHandleHeadsetPullOut() |
5530 | { |
5531 | return 0; |
5532 | } |
5533 | |
5534 | int CTv::Tv_SetDRC_OnOff(int on_off) |
5535 | { |
5536 | on_off = on_off; |
5537 | return 0; |
5538 | } |
5539 | |
5540 | int CTv::Tv_GetDRC_OnOff(void) |
5541 | { |
5542 | return 0; |
5543 | } |
5544 | |
5545 | void CTv::updateSubtitle(int pic_width, int pic_height) |
5546 | { |
5547 | TvEvent::SubtitleEvent ev; |
5548 | ev.pic_width = pic_width; |
5549 | ev.pic_height = pic_height; |
5550 | sendTvEvent(ev); |
5551 | } |
5552 | |
5553 | int CTv::setSubtitleBuffer(char *share_mem) |
5554 | { |
5555 | mSubtitle.setBuffer(share_mem); |
5556 | return 0; |
5557 | } |
5558 | |
5559 | int CTv::initSubtitle(int bitmapWidth, int bitmapHeight) |
5560 | { |
5561 | return mSubtitle.sub_init(bitmapWidth, bitmapHeight); |
5562 | } |
5563 | |
5564 | int CTv::lockSubtitle() |
5565 | { |
5566 | return mSubtitle.sub_lock(); |
5567 | } |
5568 | |
5569 | int CTv::unlockSubtitle() |
5570 | { |
5571 | return mSubtitle.sub_unlock(); |
5572 | } |
5573 | |
5574 | int CTv::getSubSwitchStatus() |
5575 | { |
5576 | return mSubtitle.sub_switch_status(); |
5577 | } |
5578 | |
5579 | int CTv::startSubtitle(int dmx_id, int pid, int page_id, int anc_page_id) |
5580 | { |
5581 | return mSubtitle.sub_start_dvb_sub(dmx_id, pid, page_id, anc_page_id); |
5582 | } |
5583 | |
5584 | int CTv::stopSubtitle() |
5585 | { |
5586 | return mSubtitle.sub_stop_dvb_sub(); |
5587 | } |
5588 | |
5589 | //-------------------------------------------------- |
5590 | |
5591 | |
5592 | //Audio Mute |
5593 | int CTv::SetAudioI2sMute(int muteStatus) |
5594 | { |
5595 | int vol = 256; |
5596 | if (muteStatus == CC_AUDIO_MUTE) { |
5597 | vol = 0; |
5598 | } else { |
5599 | vol = 256; |
5600 | } |
5601 | CFile::setFileAttrValue("/sys/class/amaudio2/aml_direct_right_gain", vol); |
5602 | CFile::setFileAttrValue("/sys/class/amaudio2/aml_direct_left_gain", vol); |
5603 | return 0; |
5604 | } |
5605 | |
5606 | int CTv::SetDacMute(int muteStatus, int mute_type) |
5607 | { |
5608 | int tmp_ret = 0; |
5609 | if (mute_type & CC_DAC_MUTE_TYPE_INTERNAL) { |
5610 | tmp_ret |= mAudioAlsa.SetInternalDacMute(muteStatus); |
5611 | } |
5612 | |
5613 | if (mute_type & CC_DAC_MUTE_TYPE_EXTERNAL) { |
5614 | int tmp_ret = 0, set_val = 0; |
5615 | int aud_arch_type = GetAudioArchitectureTypeCFG(); |
5616 | |
5617 | if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_ON_BOARD) { |
5618 | if (muteStatus == CC_AUDIO_MUTE) { |
5619 | set_val = CC_MUTE_ON; |
5620 | } else if (muteStatus == CC_AUDIO_UNMUTE) { |
5621 | set_val = CC_MUTE_OFF; |
5622 | } else { |
5623 | return -1; |
5624 | } |
5625 | |
5626 | mAudioAlsa.SetExternalDacChannelSwitch(1, set_val); |
5627 | mAudioAlsa.SetExternalDacChannelSwitch(2, set_val); |
5628 | //showboz: can disable it |
5629 | mAudioAlsa.SetExternalDacChannelSwitch(3, set_val); |
5630 | } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { |
5631 | SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_MUTE, muteStatus); |
5632 | } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_CUSTOMER_LIB) { |
5633 | mCustomerCtrl.SetMute((muteStatus == CC_AUDIO_MUTE) ? CAudioCustomerCtrl::MUTE : CAudioCustomerCtrl::UNMUTE); |
5634 | } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_DIGITAL) { |
5635 | mAudioAlsa.SetDigitalMute(muteStatus); |
5636 | } |
5637 | mAudioAlsa.setAudioPcmPlaybackMute(muteStatus); |
5638 | } |
5639 | return tmp_ret; |
5640 | } |
5641 | |
5642 | int CTv::SetAudioAVOutMute(int muteStatus) |
5643 | { |
5644 | SSMSaveAudioAVOutMuteVal(muteStatus); |
5645 | return mAudioAlsa.SetInternalDacMute(muteStatus); |
5646 | } |
5647 | |
5648 | int CTv::GetAudioAVOutMute() |
5649 | { |
5650 | int8_t tmp_ch = 0; |
5651 | SSMReadAudioAVOutMuteVal(&tmp_ch); |
5652 | return tmp_ch; |
5653 | } |
5654 | |
5655 | int CTv::SetAudioSPDIFMute(int muteStatus) |
5656 | { |
5657 | if (GetCurAudioSPDIFSwitch() == CC_SWITCH_OFF) { |
5658 | muteStatus = CC_AUDIO_MUTE; |
5659 | } |
5660 | |
5661 | SSMSaveAudioSPIDFMuteVal(muteStatus); |
5662 | return mAudioAlsa.SetSPDIFMute(muteStatus); |
5663 | } |
5664 | |
5665 | int CTv::GetAudioSPDIFMute() |
5666 | { |
5667 | int8_t tmp_ch = 0; |
5668 | SSMReadAudioSPIDFMuteVal(&tmp_ch); |
5669 | return tmp_ch; |
5670 | } |
5671 | |
5672 | int CTv::GetCurAudioSPDIFSwitch() |
5673 | { |
5674 | return mCurAudioSPDIFSwitch; |
5675 | } |
5676 | |
5677 | int CTv::SaveCurAudioSPDIFSwitch(int tmp_val) |
5678 | { |
5679 | mCurAudioSPDIFSwitch = tmp_val; |
5680 | SSMSaveAudioSPDIFSwitchVal(tmp_val); |
5681 | return tmp_val; |
5682 | } |
5683 | |
5684 | int CTv::LoadCurAudioSPDIFSwitch() |
5685 | { |
5686 | int8_t tmp_ch = 0; |
5687 | SSMReadAudioSPDIFSwitchVal(&tmp_ch); |
5688 | mCurAudioSPDIFSwitch = tmp_ch; |
5689 | if (mCurAudioSPDIFSwitch != CC_SWITCH_ON |
5690 | && mCurAudioSPDIFSwitch != CC_SWITCH_OFF) { |
5691 | SaveCurAudioSPDIFSwitch (CC_SWITCH_ON); |
5692 | } |
5693 | return mCurAudioSPDIFSwitch; |
5694 | } |
5695 | |
5696 | //Audio SPDIF Mode |
5697 | int CTv::SetAudioSPDIFMode(int tmp_val) |
5698 | { |
5699 | LOGD("%s : tmp_val = %d\n", __FUNCTION__, tmp_val); |
5700 | mCurAudioSPDIFMode = tmp_val; |
5701 | |
5702 | SetSPDIFMode(mCurAudioSPDIFMode); |
5703 | return 0; |
5704 | } |
5705 | |
5706 | int CTv::GetCurAudioSPDIFMode() |
5707 | { |
5708 | return mCurAudioSPDIFMode; |
5709 | } |
5710 | |
5711 | int CTv::SaveCurAudioSPDIFMode(int tmp_val) |
5712 | { |
5713 | mCurAudioSPDIFMode = tmp_val; |
5714 | SSMSaveAudioSPDIFModeVal(tmp_val); |
5715 | return tmp_val; |
5716 | } |
5717 | |
5718 | int CTv::LoadCurAudioSPDIFMode() |
5719 | { |
5720 | int8_t tmp_ch = 0; |
5721 | SSMReadAudioSPDIFModeVal(&tmp_ch); |
5722 | mCurAudioSPDIFMode = tmp_ch; |
5723 | if (mCurAudioSPDIFMode != CC_SPDIF_MODE_PCM |
5724 | && mCurAudioSPDIFMode != CC_SPDIF_MODE_RAW) { |
5725 | SaveCurAudioSPDIFMode (CC_SPDIF_MODE_PCM); |
5726 | } |
5727 | return mCurAudioSPDIFMode; |
5728 | } |
5729 | |
5730 | int CTv::SetAudioMasterVolume(int tmp_vol) |
5731 | { |
5732 | mCustomAudioMasterVolume = tmp_vol; |
5733 | |
5734 | //Volume Compensation |
5735 | tmp_vol += mVolumeCompensationVal; |
5736 | |
5737 | if (tmp_vol > CC_MAX_SOUND_VOL) { |
5738 | tmp_vol = CC_MAX_SOUND_VOL; |
5739 | } |
5740 | |
5741 | if (tmp_vol < CC_MIN_SOUND_VOL) { |
5742 | tmp_vol = CC_MIN_SOUND_VOL; |
5743 | } |
5744 | |
5745 | int tmp_ret = 0; |
5746 | int aud_arch_type = GetAudioArchitectureTypeCFG(); |
5747 | |
5748 | if (aud_arch_type == CC_DAC_G9TV_INTERNAL_DAC) { |
5749 | tmp_ret = mAudioAlsa.SetInternalDacMainVolume(tmp_vol); |
5750 | } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_ON_BOARD) { |
5751 | int digit_vol = 0; |
5752 | int vol_gain_val = 0; |
5753 | int vol_buf[2] = {0, 0}; |
5754 | |
5755 | //handle l&r channel volume for balance |
5756 | mAudioAlsa.CalculateBalanceVol(255, mMainVolumeBalanceVal, vol_buf); |
5757 | |
5758 | tmp_ret |= mAudioAlsa.SetExternalDacChannelVolume(1, vol_buf[0]); |
5759 | tmp_ret |= mAudioAlsa.SetExternalDacChannelVolume(2, vol_buf[1]); |
5760 | |
5761 | //handle master channel volume |
5762 | digit_vol = mAudioAlsa.TransVolumeBarVolToDigitalVol(mAudioAlsa.GetMainVolDigitLutBuf(), tmp_vol); |
5763 | |
5764 | vol_gain_val = mAudioAlsa.GetMainVolumeGain(); |
5765 | digit_vol += vol_gain_val; |
5766 | tmp_ret |= mAudioAlsa.SetExternalDacChannelVolume(0, digit_vol); |
5767 | } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { |
5768 | tmp_ret = SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_VOLUME_BAR, tmp_vol); |
5769 | } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_CUSTOMER_LIB) { |
5770 | tmp_ret = mCustomerCtrl.SetVolumeBar(tmp_vol); |
5771 | } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_DIGITAL) { |
5772 | int vol_buf[2] = {0, 0}; |
5773 | mAudioAlsa.CalculateBalanceVol(tmp_vol, mMainVolumeBalanceVal, vol_buf); |
5774 | tmp_ret = mAudioAlsa.SetDigitalMainVolume(vol_buf[0], vol_buf[1]); |
5775 | } |
5776 | if ( Get2d4gHeadsetEnable() == 1 ) { |
5777 | setAudioPcmPlaybackVolume(tmp_vol); |
5778 | } |
5779 | return 0; |
5780 | } |
5781 | |
5782 | int CTv::GetAudioMasterVolume() |
5783 | { |
5784 | return mCustomAudioMasterVolume; |
5785 | } |
5786 | |
5787 | int CTv::GetCurAudioMasterVolume() |
5788 | { |
5789 | return mCurAudioMasterVolume; |
5790 | } |
5791 | |
5792 | int CTv::SaveCurAudioMasterVolume(int tmp_vol) |
5793 | { |
5794 | mCurAudioMasterVolume = tmp_vol; |
5795 | SSMSaveAudioMasterVolume(tmp_vol); |
5796 | return tmp_vol; |
5797 | } |
5798 | |
5799 | int CTv::LoadCurAudioMasterVolume() |
5800 | { |
5801 | int8_t tmp_ch = 0; |
5802 | SSMReadAudioMasterVolume(&tmp_ch); |
5803 | mCurAudioMasterVolume = tmp_ch; |
5804 | if (mCurAudioMasterVolume < CC_MIN_SOUND_VOL |
5805 | || mCurAudioMasterVolume > CC_MAX_SOUND_VOL) { |
5806 | SaveCurAudioMasterVolume (CC_DEF_SOUND_VOL); |
5807 | } |
5808 | mCustomAudioMasterVolume = mCurAudioMasterVolume; |
5809 | |
5810 | return mCurAudioMasterVolume; |
5811 | } |
5812 | |
5813 | int CTv::SetAudioBalance(int tmp_val) |
5814 | { |
5815 | mCustomAudioBalance = tmp_val; |
5816 | |
5817 | int aud_arch_type = GetAudioArchitectureTypeCFG(); |
5818 | |
5819 | mMainVolumeBalanceVal = tmp_val; |
5820 | |
5821 | if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { |
5822 | SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_BALANCE, mMainVolumeBalanceVal); |
5823 | } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_CUSTOMER_LIB) { |
5824 | mCustomerCtrl.SetBlance(mMainVolumeBalanceVal); |
5825 | } else { |
5826 | SetAudioMasterVolume(GetAudioMasterVolume()); |
5827 | } |
5828 | return 0; |
5829 | } |
5830 | |
5831 | int CTv::GetAudioBalance() |
5832 | { |
5833 | return mCustomAudioBalance; |
5834 | } |
5835 | |
5836 | int CTv::GetCurAudioBalance() |
5837 | { |
5838 | return mCurAudioBalance; |
5839 | } |
5840 | |
5841 | int CTv::SaveCurAudioBalance(int tmp_val) |
5842 | { |
5843 | mCurAudioBalance = tmp_val; |
5844 | SSMSaveAudioBalanceVal(tmp_val); |
5845 | return tmp_val; |
5846 | } |
5847 | |
5848 | int CTv::LoadCurAudioBalance() |
5849 | { |
5850 | int8_t tmp_ch = 0; |
5851 | SSMReadAudioBalanceVal(&tmp_ch); |
5852 | mCurAudioBalance = tmp_ch; |
5853 | if (mCurAudioBalance < CC_MIN_SOUND_BALANCE_VAL |
5854 | || mCurAudioBalance > CC_MAX_SOUND_BALANCE_VAL) { |
5855 | SaveCurAudioBalance (CC_DEF_SOUND_BALANCE_VAL); |
5856 | } |
5857 | |
5858 | mCustomAudioBalance = mCurAudioBalance; |
5859 | |
5860 | return mCurAudioBalance; |
5861 | } |
5862 | |
5863 | int CTv::SetAudioVolumeCompensationVal(int tmp_vol_comp_val) |
5864 | { |
5865 | mVolumeCompensationVal = tmp_vol_comp_val; |
5866 | LOGD("%s, new vol comp value = %d.\n", __FUNCTION__, tmp_vol_comp_val); |
5867 | return mVolumeCompensationVal; |
5868 | } |
5869 | |
5870 | int CTv::SetAudioSupperBassVolume(int tmp_vol) |
5871 | { |
5872 | mCustomAudioSupperBassVolume = tmp_vol; |
5873 | |
5874 | int aud_arch_type = GetAudioArchitectureTypeCFG(); |
5875 | int tmp_ret = 0; |
5876 | |
5877 | if (aud_arch_type == CC_DAC_G9TV_INTERNAL_DAC) { |
5878 | return 0; |
5879 | } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_ON_BOARD) { |
5880 | int digit_vol = 0; |
5881 | int vol_gain_val = 0; |
5882 | |
5883 | digit_vol = mAudioAlsa.TransVolumeBarVolToDigitalVol(mAudioAlsa.GetMainVolDigitLutBuf(), tmp_vol); |
5884 | |
5885 | vol_gain_val = mAudioAlsa.GetSupperBassVolumeGain(); |
5886 | digit_vol += vol_gain_val; |
5887 | if (digit_vol < CC_MIN_DAC_SUB_WOOFER_VOLUME) { |
5888 | digit_vol = CC_MIN_DAC_SUB_WOOFER_VOLUME; |
5889 | } else if (digit_vol > CC_MAX_DAC_SUB_WOOFER_VOLUME) { |
5890 | digit_vol = CC_MAX_DAC_SUB_WOOFER_VOLUME; |
5891 | } |
5892 | |
5893 | tmp_ret = mAudioAlsa.SetExternalDacChannelVolume(3, digit_vol); |
5894 | } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { |
5895 | tmp_ret = SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_SUBCHANNEL_VOLUME, tmp_vol); |
5896 | } |
5897 | |
5898 | return tmp_ret; |
5899 | } |
5900 | |
5901 | int CTv::GetAudioSupperBassVolume() |
5902 | { |
5903 | return mCustomAudioSupperBassVolume; |
5904 | } |
5905 | |
5906 | int CTv::GetCurAudioSupperBassVolume() |
5907 | { |
5908 | return mCurAudioSupperBassVolume; |
5909 | } |
5910 | |
5911 | int CTv::SaveCurAudioSupperBassVolume(int tmp_vol) |
5912 | { |
5913 | mCurAudioSupperBassVolume = tmp_vol; |
5914 | SSMSaveAudioSupperBassVolume(tmp_vol); |
5915 | |
5916 | return tmp_vol; |
5917 | } |
5918 | |
5919 | int CTv::LoadCurAudioSupperBassVolume() |
5920 | { |
5921 | int8_t tmp_ch = 0; |
5922 | SSMReadAudioSupperBassVolume(&tmp_ch); |
5923 | mCurAudioSupperBassVolume = tmp_ch; |
5924 | if (mCurAudioSupperBassVolume < CC_MIN_SUPPERBASS_VOL |
5925 | || mCurAudioSupperBassVolume > CC_MAX_SUPPERBASS_VOL) { |
5926 | SaveCurAudioSupperBassVolume (CC_DEF_SUPPERBASS_VOL); |
5927 | } |
5928 | mCustomAudioSupperBassVolume = mCurAudioSupperBassVolume; |
5929 | |
5930 | return mCurAudioSupperBassVolume; |
5931 | } |
5932 | |
5933 | int CTv::SetAudioSupperBassSwitch(int tmp_val) |
5934 | { |
5935 | mCustomAudioSupperBassSwitch = tmp_val; |
5936 | |
5937 | if (GetAudioSupperBassSwitch() == CC_SWITCH_OFF) { |
5938 | return SetAudioSupperBassVolume(CC_MIN_SUPPERBASS_VOL); |
5939 | } |
5940 | |
5941 | return SetAudioSupperBassVolume(GetAudioSupperBassVolume()); |
5942 | } |
5943 | |
5944 | int CTv::GetAudioSupperBassSwitch() |
5945 | { |
5946 | if (GetAudioSupperBassSwitchDisableCFG() != 0) { |
5947 | return CC_SWITCH_ON; |
5948 | } |
5949 | |
5950 | return mCustomAudioSupperBassSwitch; |
5951 | } |
5952 | |
5953 | int CTv::GetCurAudioSupperBassSwitch() |
5954 | { |
5955 | if (GetAudioSupperBassSwitchDisableCFG() != 0) { |
5956 | return CC_SWITCH_ON; |
5957 | } |
5958 | |
5959 | return mCurAudioSupperBassSwitch; |
5960 | } |
5961 | |
5962 | int CTv::SaveCurAudioSupperBassSwitch(int tmp_val) |
5963 | { |
5964 | mCurAudioSupperBassSwitch = tmp_val; |
5965 | SSMSaveAudioSupperBassSwitch(tmp_val); |
5966 | SetSupperBassSRSSpeakerSize(); |
5967 | return tmp_val; |
5968 | } |
5969 | |
5970 | int CTv::LoadCurAudioSupperBassSwitch() |
5971 | { |
5972 | int8_t tmp_ch = 0; |
5973 | SSMReadAudioSupperBassSwitch(&tmp_ch); |
5974 | mCurAudioSupperBassSwitch = tmp_ch; |
5975 | if (mCurAudioSupperBassSwitch != CC_SWITCH_ON |
5976 | && mCurAudioSupperBassSwitch != CC_SWITCH_OFF) { |
5977 | SaveCurAudioSupperBassSwitch (CC_SWITCH_OFF); |
5978 | } |
5979 | mCustomAudioSupperBassSwitch = mCurAudioSupperBassSwitch; |
5980 | |
5981 | return mCurAudioSupperBassSwitch; |
5982 | } |
5983 | |
5984 | void CTv::SetSupperBassSRSSpeakerSize() |
5985 | { |
5986 | int tmp_speakersize = -1; |
5987 | |
5988 | if (GetAudioSrsTruBass() == CC_SWITCH_ON) { |
5989 | tmp_speakersize = GetAudioSRSSupperBassTrubassSpeakerSizeCfg(); |
5990 | if (tmp_speakersize >= 0) { |
5991 | mAudioEffect.SetSrsTrubassSpeakerSize(tmp_speakersize); |
5992 | } |
5993 | } |
5994 | } |
5995 | |
5996 | int CTv::SetAudioSRSSurround(int tmp_val) |
5997 | { |
5998 | mCustomAudioSRSSurround = tmp_val; |
5999 | RefreshSrsEffectAndDacGain(); |
6000 | return 0; |
6001 | } |
6002 | |
6003 | int CTv::GetAudioSRSSurround() |
6004 | { |
6005 | return mCustomAudioSRSSurround; |
6006 | } |
6007 | |
6008 | int CTv::GetCurAudioSRSSurround() |
6009 | { |
6010 | return mCurAudioSRSSurround; |
6011 | } |
6012 | |
6013 | int CTv::SaveCurAudioSrsSurround(int tmp_val) |
6014 | { |
6015 | mCurAudioSRSSurround = tmp_val; |
6016 | SSMSaveAudioSRSSurroundSwitch(tmp_val); |
6017 | return tmp_val; |
6018 | } |
6019 | |
6020 | int CTv::LoadCurAudioSrsSurround() |
6021 | { |
6022 | int8_t tmp_ch = 0; |
6023 | |
6024 | SSMReadAudioSRSSurroundSwitch(&tmp_ch); |
6025 | mCurAudioSRSSurround = tmp_ch; |
6026 | if (mCurAudioSRSSurround != CC_SWITCH_ON |
6027 | && mCurAudioSRSSurround != CC_SWITCH_OFF) { |
6028 | SaveCurAudioSrsSurround (CC_SWITCH_OFF); |
6029 | } |
6030 | mCustomAudioSRSSurround = mCurAudioSRSSurround; |
6031 | |
6032 | return mCurAudioSRSSurround; |
6033 | } |
6034 | |
6035 | int CTv::SetAudioSrsDialogClarity(int tmp_val) |
6036 | { |
6037 | mCustomAudioSrsDialogClarity = tmp_val; |
6038 | RefreshSrsEffectAndDacGain(); |
6039 | return 0; |
6040 | } |
6041 | |
6042 | int CTv::GetAudioSrsDialogClarity() |
6043 | { |
6044 | return mCustomAudioSrsDialogClarity; |
6045 | } |
6046 | |
6047 | int CTv::GetCurAudioSrsDialogClarity() |
6048 | { |
6049 | return mCurAudioSrsDialogClarity; |
6050 | } |
6051 | |
6052 | int CTv::SaveCurAudioSrsDialogClarity(int tmp_val) |
6053 | { |
6054 | mCurAudioSrsDialogClarity = tmp_val; |
6055 | SSMSaveAudioSRSDialogClaritySwitch(tmp_val); |
6056 | return tmp_val; |
6057 | } |
6058 | |
6059 | int CTv::LoadCurAudioSrsDialogClarity() |
6060 | { |
6061 | int8_t tmp_ch = 0; |
6062 | |
6063 | SSMReadAudioSRSDialogClaritySwitch(&tmp_ch); |
6064 | mCurAudioSrsDialogClarity = tmp_ch; |
6065 | if (mCurAudioSrsDialogClarity != CC_SWITCH_ON |
6066 | && mCurAudioSrsDialogClarity != CC_SWITCH_OFF) { |
6067 | SaveCurAudioSrsDialogClarity (CC_SWITCH_OFF); |
6068 | } |
6069 | mCustomAudioSrsDialogClarity = mCurAudioSrsDialogClarity; |
6070 | |
6071 | return mCurAudioSrsDialogClarity; |
6072 | } |
6073 | |
6074 | int CTv::SetAudioSrsTruBass(int tmp_val) |
6075 | { |
6076 | mCustomAudioSrsTruBass = tmp_val; |
6077 | RefreshSrsEffectAndDacGain(); |
6078 | return 0; |
6079 | } |
6080 | |
6081 | int CTv::GetAudioSrsTruBass() |
6082 | { |
6083 | return mCustomAudioSrsTruBass; |
6084 | } |
6085 | |
6086 | int CTv::GetCurAudioSrsTruBass() |
6087 | { |
6088 | return mCurAudioSrsTruBass; |
6089 | } |
6090 | |
6091 | int CTv::SaveCurAudioSrsTruBass(int tmp_val) |
6092 | { |
6093 | mCurAudioSrsTruBass = tmp_val; |
6094 | SSMSaveAudioSRSTruBassSwitch(tmp_val); |
6095 | return tmp_val; |
6096 | } |
6097 | |
6098 | int CTv::LoadCurAudioSrsTruBass() |
6099 | { |
6100 | int8_t tmp_ch = 0; |
6101 | |
6102 | SSMReadAudioSRSTruBassSwitch(&tmp_ch); |
6103 | mCurAudioSrsTruBass = tmp_ch; |
6104 | if (mCurAudioSrsTruBass != CC_SWITCH_ON |
6105 | && mCurAudioSrsTruBass != CC_SWITCH_OFF) { |
6106 | SaveCurAudioSrsTruBass (CC_SWITCH_OFF); |
6107 | } |
6108 | mCustomAudioSrsTruBass = mCurAudioSrsTruBass; |
6109 | |
6110 | return mCurAudioSrsTruBass; |
6111 | } |
6112 | |
6113 | void CTv::RefreshSrsEffectAndDacGain() |
6114 | { |
6115 | int tmp_gain_val = 0; |
6116 | int surround_switch = CC_SWITCH_OFF; |
6117 | int trubass_switch = CC_SWITCH_OFF; |
6118 | int dialogclarity_switch = CC_SWITCH_OFF; |
6119 | trubass_switch = GetAudioSrsTruBass(); |
6120 | dialogclarity_switch = GetAudioSrsDialogClarity(); |
6121 | surround_switch = GetAudioSRSSurround(); |
6122 | |
6123 | if (GetAudioSRSSourroundEnableCFG() == 0) { |
6124 | return; |
6125 | } |
6126 | |
6127 | if (surround_switch == CC_SWITCH_ON) { |
6128 | mAudioEffect.SetSrsSurroundSwitch(CC_SWITCH_ON); |
6129 | tmp_gain_val = GetAudioSRSGainCfg("audio.srs.sourround.gain", 50); |
6130 | mAudioEffect.SetSrsSurroundGain(tmp_gain_val); |
6131 | |
6132 | int input_gain_val = GetAudioSRSGainCfg("audio.srs.input.gain", 50); |
6133 | int out_gain_val = GetAudioSRSGainCfg("audio.srs.output.gain", 50); |
6134 | mAudioEffect.SetSrsInputOutputGain(input_gain_val, out_gain_val); |
6135 | |
6136 | if (trubass_switch == CC_SWITCH_ON |
6137 | && dialogclarity_switch == CC_SWITCH_OFF) { |
6138 | |
6139 | mAudioEffect.SetSrsTruBassSwitch (CC_SWITCH_ON); |
6140 | tmp_gain_val = GetAudioSRSGainCfg("audio.srs.trubass.gain", 50); |
6141 | mAudioEffect.SetSrsTruBassGain(tmp_gain_val); |
6142 | tmp_gain_val = GetAudioSRSGainCfg("audio.srs.trubass.speakersize", 2); |
6143 | mAudioEffect.SetSrsTrubassSpeakerSize(tmp_gain_val); |
6144 | |
6145 | mAudioEffect.SetSrsDialogClaritySwitch (CC_SWITCH_OFF); |
6146 | |
6147 | } else if (trubass_switch == CC_SWITCH_OFF |
6148 | && dialogclarity_switch == CC_SWITCH_ON) { |
6149 | |
6150 | mAudioEffect.SetSrsDialogClaritySwitch (CC_SWITCH_ON); |
6151 | tmp_gain_val = GetAudioSRSGainCfg("audio.srs.dialogclarity.gain", 30); |
6152 | mAudioEffect.SetSrsDialogClarityGain(tmp_gain_val); |
6153 | tmp_gain_val = GetAudioSRSGainCfg("audio.srs.definition.gain", 20); |
6154 | mAudioEffect.SetSrsDefinitionGain(tmp_gain_val); |
6155 | |
6156 | mAudioEffect.SetSrsTruBassSwitch (CC_SWITCH_OFF); |
6157 | |
6158 | } else if (trubass_switch == CC_SWITCH_ON |
6159 | && dialogclarity_switch == CC_SWITCH_ON) { |
6160 | |
6161 | mAudioEffect.SetSrsTruBassSwitch (CC_SWITCH_ON); |
6162 | tmp_gain_val = GetAudioSRSGainCfg("audio.srs.trubass.gain", 50); |
6163 | mAudioEffect.SetSrsTruBassGain(tmp_gain_val); |
6164 | tmp_gain_val = GetAudioSRSGainCfg("audio.srs.trubass.speakersize", 2); |
6165 | mAudioEffect.SetSrsTrubassSpeakerSize(tmp_gain_val); |
6166 | |
6167 | mAudioEffect.SetSrsDialogClaritySwitch(CC_SWITCH_ON); |
6168 | tmp_gain_val = GetAudioSRSGainCfg("audio.srs.dialogclarity.gain", 30); |
6169 | mAudioEffect.SetSrsDialogClarityGain(tmp_gain_val); |
6170 | tmp_gain_val = GetAudioSRSGainCfg("audio.srs.definition.gain", 20); |
6171 | mAudioEffect.SetSrsDefinitionGain(tmp_gain_val); |
6172 | |
6173 | } else if (trubass_switch == CC_SWITCH_OFF |
6174 | && dialogclarity_switch == CC_SWITCH_OFF) { |
6175 | mAudioEffect.SetSrsTruBassSwitch (CC_SWITCH_OFF); |
6176 | mAudioEffect.SetSrsDialogClaritySwitch(CC_SWITCH_OFF); |
6177 | } |
6178 | SetSupperBassSRSSpeakerSize(); |
6179 | } else { |
6180 | mAudioEffect.SetSrsSurroundSwitch (CC_SWITCH_OFF); |
6181 | mAudioEffect.SetSrsTruBassSwitch(CC_SWITCH_OFF); |
6182 | mAudioEffect.SetSrsDialogClaritySwitch(CC_SWITCH_OFF); |
6183 | } |
6184 | //Refesh DAC gain |
6185 | int main_gain_val = 0; |
6186 | if (surround_switch == CC_SWITCH_ON) { |
6187 | main_gain_val = GetAudioEffectAmplifierGainCfg("audio.srs.sourround.ampmaster.gain", 6, 24); |
6188 | if (dialogclarity_switch == CC_SWITCH_ON |
6189 | && trubass_switch == CC_SWITCH_OFF) { |
6190 | main_gain_val = GetAudioEffectAmplifierGainCfg("audio.srs.dialogclarity.ampmaster.gain", 6, 24); |
6191 | } else if (dialogclarity_switch == CC_SWITCH_OFF |
6192 | && trubass_switch == CC_SWITCH_ON) { |
6193 | main_gain_val = GetAudioEffectAmplifierGainCfg("audio.srs.trubass.ampmaster.gain", 6, 24); |
6194 | } else if (dialogclarity_switch == CC_SWITCH_ON |
6195 | && trubass_switch == CC_SWITCH_ON) { |
6196 | main_gain_val = GetAudioEffectAmplifierGainCfg("audio.srs.trubass.dialogclarity.ampmaster.gain", 6, 24); |
6197 | } |
6198 | } |
6199 | mAudioAlsa.SetMainVolumeGain(main_gain_val); |
6200 | } |
6201 | |
6202 | int CTv::SetAudioBassVolume(int tmp_vol) |
6203 | { |
6204 | int nMinBassVol = 0, nMaxBassVol = 0; |
6205 | |
6206 | nMinBassVol = GetBassUIMinGainVal(); |
6207 | nMaxBassVol = GetBassUIMaxGainVal(); |
6208 | |
6209 | if (tmp_vol < nMinBassVol || tmp_vol > nMaxBassVol) { |
6210 | tmp_vol = (nMaxBassVol + nMinBassVol) / 2; |
6211 | } |
6212 | |
6213 | mCustomAudioBassVolume = tmp_vol; |
6214 | tmp_vol = MappingTrebleBassAndEqualizer(GetAudioBassVolume(), 0, |
6215 | nMinBassVol, nMaxBassVol); |
6216 | return SetSpecialIndexEQGain(CC_EQ_BASS_IND, tmp_vol); |
6217 | } |
6218 | |
6219 | int CTv::GetAudioBassVolume() |
6220 | { |
6221 | return mCustomAudioBassVolume; |
6222 | } |
6223 | |
6224 | int CTv::GetCurAudioBassVolume() |
6225 | { |
6226 | return mCurAudioBassVolume; |
6227 | } |
6228 | |
6229 | int CTv::SaveCurAudioBassVolume(int tmp_vol) |
6230 | { |
6231 | int nMinBassVol = 0, nMaxBassVol = 0; |
6232 | |
6233 | nMinBassVol = GetBassUIMinGainVal(); |
6234 | nMaxBassVol = GetBassUIMaxGainVal(); |
6235 | |
6236 | if (tmp_vol < nMinBassVol || tmp_vol > nMaxBassVol) { |
6237 | tmp_vol = (nMaxBassVol + nMinBassVol) / 2; |
6238 | } |
6239 | |
6240 | RealSaveCurAudioBassVolume(tmp_vol, 1); |
6241 | |
6242 | tmp_vol = MappingTrebleBassAndEqualizer(GetCurAudioBassVolume(), 0, |
6243 | nMinBassVol, nMaxBassVol); |
6244 | return SaveSpecialIndexEQGain(CC_EQ_BASS_IND, tmp_vol); |
6245 | } |
6246 | |
6247 | int CTv::RealSaveCurAudioBassVolume(int tmp_vol, int sound_mode_judge) |
6248 | { |
6249 | mCurAudioBassVolume = tmp_vol; |
6250 | SSMSaveAudioBassVolume(tmp_vol); |
6251 | |
6252 | if (sound_mode_judge == 1) { |
6253 | if (GetAudioSoundMode() != CC_SOUND_MODE_USER) { |
6254 | SaveCurAudioSoundMode (CC_SOUND_MODE_USER); |
6255 | mCustomAudioSoundMode = mCurAudioSoundMode; |
6256 | } |
6257 | } |
6258 | return mCurAudioBassVolume; |
6259 | } |
6260 | |
6261 | int CTv::LoadCurAudioBassVolume() |
6262 | { |
6263 | int nMinBassVol = 0, nMaxBassVol = 0; |
6264 | int8_t tmp_ch = 0; |
6265 | |
6266 | nMinBassVol = GetBassUIMinGainVal(); |
6267 | nMaxBassVol = GetBassUIMaxGainVal(); |
6268 | |
6269 | SSMReadAudioBassVolume(&tmp_ch); |
6270 | mCurAudioBassVolume = tmp_ch; |
6271 | if (mCurAudioBassVolume < nMinBassVol |
6272 | || mCurAudioBassVolume > nMaxBassVol) { |
6273 | RealSaveCurAudioBassVolume((nMaxBassVol + nMinBassVol) / 2, 0); |
6274 | } |
6275 | |
6276 | mCustomAudioBassVolume = mCurAudioBassVolume; |
6277 | return mCurAudioBassVolume; |
6278 | } |
6279 | |
6280 | int CTv::SetAudioTrebleVolume(int tmp_vol) |
6281 | { |
6282 | int nMinTrebleVol = 0, nMaxTrebleVol = 0; |
6283 | |
6284 | nMinTrebleVol = GetTrebleUIMinGainVal(); |
6285 | nMaxTrebleVol = GetTrebleUIMaxGainVal(); |
6286 | |
6287 | if (tmp_vol < nMinTrebleVol || tmp_vol > nMaxTrebleVol) { |
6288 | tmp_vol = (nMaxTrebleVol + nMinTrebleVol) / 2; |
6289 | } |
6290 | |
6291 | mCustomAudioTrebleVolume = tmp_vol; |
6292 | |
6293 | tmp_vol = MappingTrebleBassAndEqualizer(GetAudioTrebleVolume(), 0, |
6294 | nMinTrebleVol, nMaxTrebleVol); |
6295 | return SetSpecialIndexEQGain(CC_EQ_TREBLE_IND, tmp_vol); |
6296 | } |
6297 | |
6298 | int CTv::GetAudioTrebleVolume() |
6299 | { |
6300 | return mCustomAudioTrebleVolume; |
6301 | } |
6302 | |
6303 | int CTv::GetCurAudioTrebleVolume() |
6304 | { |
6305 | return mCurAudioTrebleVolume; |
6306 | } |
6307 | |
6308 | int CTv::SaveCurAudioTrebleVolume(int tmp_vol) |
6309 | { |
6310 | int nMinTrebleVol = 0, nMaxTrebleVol = 0; |
6311 | |
6312 | nMinTrebleVol = GetTrebleUIMinGainVal(); |
6313 | nMaxTrebleVol = GetTrebleUIMaxGainVal(); |
6314 | |
6315 | if (tmp_vol < nMinTrebleVol || tmp_vol > nMaxTrebleVol) { |
6316 | tmp_vol = (nMaxTrebleVol + nMinTrebleVol) / 2; |
6317 | } |
6318 | |
6319 | RealSaveCurAudioTrebleVolume(tmp_vol, 1); |
6320 | |
6321 | tmp_vol = MappingTrebleBassAndEqualizer(GetCurAudioTrebleVolume(), 0, |
6322 | nMinTrebleVol, nMaxTrebleVol); |
6323 | return SaveSpecialIndexEQGain(CC_EQ_TREBLE_IND, tmp_vol); |
6324 | } |
6325 | |
6326 | int CTv::RealSaveCurAudioTrebleVolume(int tmp_vol, int sound_mode_judge) |
6327 | { |
6328 | mCurAudioTrebleVolume = tmp_vol; |
6329 | SSMSaveAudioTrebleVolume(tmp_vol); |
6330 | |
6331 | if (sound_mode_judge == 1) { |
6332 | if (GetAudioSoundMode() != CC_SOUND_MODE_USER) { |
6333 | SaveCurAudioSoundMode (CC_SOUND_MODE_USER); |
6334 | mCustomAudioSoundMode = mCurAudioSoundMode; |
6335 | } |
6336 | } |
6337 | |
6338 | return mCurAudioTrebleVolume; |
6339 | } |
6340 | |
6341 | int CTv::LoadCurAudioTrebleVolume() |
6342 | { |
6343 | int nMinTrebleVol = 0, nMaxTrebleVol = 0; |
6344 | int8_t tmp_ch = 0; |
6345 | |
6346 | nMinTrebleVol = GetTrebleUIMinGainVal(); |
6347 | nMaxTrebleVol = GetTrebleUIMaxGainVal(); |
6348 | |
6349 | SSMReadAudioTrebleVolume(&tmp_ch); |
6350 | mCurAudioTrebleVolume = tmp_ch; |
6351 | if (mCurAudioTrebleVolume < nMinTrebleVol |
6352 | || mCurAudioTrebleVolume > nMaxTrebleVol) { |
6353 | RealSaveCurAudioTrebleVolume((nMaxTrebleVol + nMinTrebleVol) / 2, 0); |
6354 | } |
6355 | |
6356 | mCustomAudioTrebleVolume = mCurAudioTrebleVolume; |
6357 | return mCurAudioTrebleVolume; |
6358 | } |
6359 | |
6360 | int CTv::SetAudioSoundMode(int tmp_val) |
6361 | { |
6362 | mCustomAudioSoundMode = tmp_val; |
6363 | SetSpecialModeEQGain(mCustomAudioSoundMode); |
6364 | |
6365 | HandleTrebleBassVolume(); |
6366 | return 0; |
6367 | } |
6368 | |
6369 | int CTv::GetAudioSoundMode() |
6370 | { |
6371 | return mCustomAudioSoundMode; |
6372 | } |
6373 | |
6374 | int CTv::GetCurAudioSoundMode() |
6375 | { |
6376 | return mCurAudioSoundMode; |
6377 | } |
6378 | |
6379 | int CTv::SaveCurAudioSoundMode(int tmp_val) |
6380 | { |
6381 | mCurAudioSoundMode = tmp_val; |
6382 | SSMSaveAudioSoundModeVal(tmp_val); |
6383 | return tmp_val; |
6384 | } |
6385 | |
6386 | int CTv::LoadCurAudioSoundMode() |
6387 | { |
6388 | int8_t tmp_ch = 0; |
6389 | SSMReadAudioSoundModeVal(&tmp_ch); |
6390 | mCurAudioSoundMode = tmp_ch; |
6391 | if (mCurAudioSoundMode < CC_SOUND_MODE_START |
6392 | || mCurAudioSoundMode > CC_SOUND_MODE_END) { |
6393 | SaveCurAudioSoundMode (CC_SOUND_MODE_STD); |
6394 | } |
6395 | mCustomAudioSoundMode = mCurAudioSoundMode; |
6396 | return mCurAudioSoundMode; |
6397 | } |
6398 | |
6399 | int CTv::HandleTrebleBassVolume() |
6400 | { |
6401 | int tmp_vol = 0; |
6402 | int tmpEQGainBuf[128] = { 0 }; |
6403 | int8_t tmp_ch = 0; |
6404 | |
6405 | GetCustomEQGain(tmpEQGainBuf); |
6406 | |
6407 | tmp_vol = MappingTrebleBassAndEqualizer(tmpEQGainBuf[CC_EQ_TREBLE_IND], 1, |
6408 | GetTrebleUIMinGainVal(), GetTrebleUIMaxGainVal()); |
6409 | mCustomAudioTrebleVolume = tmp_vol; |
6410 | mCurAudioTrebleVolume = mCustomAudioTrebleVolume; |
6411 | tmp_ch = mCustomAudioTrebleVolume; |
6412 | SSMSaveAudioTrebleVolume(tmp_ch); |
6413 | |
6414 | tmp_vol = MappingTrebleBassAndEqualizer(tmpEQGainBuf[CC_EQ_BASS_IND], 1, |
6415 | GetBassUIMinGainVal(), GetBassUIMaxGainVal()); |
6416 | mCustomAudioBassVolume = tmp_vol; |
6417 | mCurAudioBassVolume = mCustomAudioBassVolume; |
6418 | tmp_ch = mCustomAudioBassVolume; |
6419 | SSMSaveAudioBassVolume(tmp_ch); |
6420 | return 0; |
6421 | } |
6422 | |
6423 | int CTv::SetAudioWallEffect(int tmp_val) |
6424 | { |
6425 | int tmp_treble_val; |
6426 | int tmp_type = 0; |
6427 | |
6428 | mCustomAudioWallEffect = tmp_val; |
6429 | |
6430 | tmp_type = GetAudioWallEffectTypeCfg(); |
6431 | if (tmp_type == 0) { |
6432 | SetCustomEQGain(); |
6433 | } else if (tmp_type == 1) { |
6434 | int aud_arch_type = GetAudioArchitectureTypeCFG(); |
6435 | if (aud_arch_type == CC_DAC_G9TV_INTERNAL_DAC) { |
6436 | return 0; |
6437 | } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_ON_BOARD) { |
6438 | mAudioAlsa.SetExternalDacEQMode(tmp_val); |
6439 | } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { |
6440 | SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_EQ_MODE, tmp_val); |
6441 | } |
6442 | } |
6443 | return 0; |
6444 | } |
6445 | |
6446 | int CTv::GetAudioWallEffect() |
6447 | { |
6448 | return mCustomAudioWallEffect; |
6449 | } |
6450 | |
6451 | int CTv::GetCurAudioWallEffect() |
6452 | { |
6453 | return mCurAudioWallEffect; |
6454 | } |
6455 | |
6456 | int CTv::SaveCurAudioWallEffect(int tmp_val) |
6457 | { |
6458 | mCurAudioWallEffect = tmp_val; |
6459 | SSMSaveAudioWallEffectSwitch(tmp_val); |
6460 | return tmp_val; |
6461 | } |
6462 | |
6463 | int CTv::LoadCurAudioWallEffect() |
6464 | { |
6465 | int8_t tmp_ch = 0; |
6466 | SSMReadAudioWallEffectSwitch(&tmp_ch); |
6467 | mCurAudioWallEffect = tmp_ch; |
6468 | if (mCurAudioWallEffect != CC_SWITCH_ON |
6469 | && mCurAudioWallEffect != CC_SWITCH_OFF) { |
6470 | SaveCurAudioWallEffect (CC_SWITCH_OFF); |
6471 | } |
6472 | |
6473 | mCustomAudioWallEffect = mCurAudioWallEffect; |
6474 | return mCurAudioWallEffect; |
6475 | } |
6476 | |
6477 | int CTv::SetAudioEQMode(int tmp_val) |
6478 | { |
6479 | mCustomAudioEQMode = tmp_val; |
6480 | return 0; |
6481 | } |
6482 | |
6483 | int CTv::GetAudioEQMode() |
6484 | { |
6485 | return mCustomAudioEQMode; |
6486 | } |
6487 | |
6488 | int CTv::GetCurAudioEQMode() |
6489 | { |
6490 | return mCurAudioEQMode; |
6491 | } |
6492 | |
6493 | int CTv::SaveCurAudioEQMode(int tmp_val) |
6494 | { |
6495 | mCurAudioEQMode = tmp_val; |
6496 | SSMSaveAudioEQModeVal(tmp_val); |
6497 | |
6498 | return tmp_val; |
6499 | } |
6500 | |
6501 | int CTv::LoadCurAudioEQMode() |
6502 | { |
6503 | int8_t tmp_ch = 0; |
6504 | SSMReadAudioEQModeVal(&tmp_ch); |
6505 | mCurAudioEQMode = tmp_ch; |
6506 | if (mCurAudioEQMode < CC_EQ_MODE_START |
6507 | || mCurAudioEQMode > CC_EQ_MODE_END) { |
6508 | SaveCurAudioEQMode (CC_EQ_MODE_START); |
6509 | } |
6510 | mCustomAudioEQMode = mCurAudioEQMode; |
6511 | |
6512 | return mCurAudioEQMode; |
6513 | } |
6514 | |
6515 | int CTv::GetAudioEQRange(int range_buf[]) |
6516 | { |
6517 | range_buf[0] = CC_MIN_EQ_GAIN_VAL; |
6518 | range_buf[1] = CC_MAX_EQ_GAIN_VAL; |
6519 | return 0; |
6520 | } |
6521 | |
6522 | int CTv::GetAudioEQBandCount() |
6523 | { |
6524 | return mAudioEffect.GetEQBandCount(); |
6525 | } |
6526 | |
6527 | int CTv::SetAudioEQGain(int gain_buf[]) |
6528 | { |
6529 | return AudioSetEQGain(gain_buf); |
6530 | } |
6531 | |
6532 | int CTv::GetAudioEQGain(int gain_buf[]) |
6533 | { |
6534 | return GetCustomEQGain(gain_buf); |
6535 | } |
6536 | |
6537 | int CTv::GetCurAudioEQGain(int gain_buf[]) |
6538 | { |
6539 | RealReadCurAudioEQGain(gain_buf); |
6540 | return 0; |
6541 | } |
6542 | |
6543 | int CTv::SaveCurAudioEQGain(int gain_buf[]) |
6544 | { |
6545 | return RealSaveCurAudioEQGain(gain_buf, 1); |
6546 | } |
6547 | |
6548 | int CTv::RealReadCurAudioEQGain(int gain_buf[]) |
6549 | { |
6550 | ArrayCopy(gain_buf, mCurEQGainBuf, GetAudioEQBandCount()); |
6551 | return 0; |
6552 | } |
6553 | |
6554 | int CTv::RealSaveCurAudioEQGain(int gain_buf[], int sound_mode_judge) |
6555 | { |
6556 | ArrayCopy(mCurEQGainBuf, gain_buf, GetAudioEQBandCount()); |
6557 | ArrayCopy(mCurEQGainChBuf, gain_buf, GetAudioEQBandCount()); |
6558 | SSMSaveAudioEQGain(0, GetAudioEQBandCount(), mCurEQGainChBuf); |
6559 | |
6560 | if (sound_mode_judge == 1) { |
6561 | HandleTrebleBassVolume(); |
6562 | SaveCurAudioSoundMode (CC_SOUND_MODE_USER); |
6563 | mCustomAudioSoundMode = mCurAudioSoundMode; |
6564 | } |
6565 | |
6566 | return 0; |
6567 | } |
6568 | |
6569 | int CTv::LoadCurAudioEQGain() |
6570 | { |
6571 | SSMReadAudioEQGain(0, GetAudioEQBandCount(), mCurEQGainChBuf); |
6572 | ArrayCopy(mCurEQGainBuf, mCurEQGainChBuf, GetAudioEQBandCount()); |
6573 | |
6574 | for (int i = 0; i < GetAudioEQBandCount(); i++) { |
6575 | if (mCurEQGainBuf[i] & 0x80) { |
6576 | mCurEQGainBuf[i] = mCurEQGainBuf[i] - 256; |
6577 | } |
6578 | } |
6579 | return 0; |
6580 | } |
6581 | |
6582 | int CTv::SetAudioEQSwitch(int switch_val) |
6583 | { |
6584 | return mAudioEffect.SetEQSwitch(switch_val); |
6585 | } |
6586 | |
6587 | int CTv::SetDbxTvMode(int mode, int son_value, int vol_value, int sur_value) |
6588 | { |
6589 | return mAudioEffect.DbxTv_SetMode(mode, son_value, vol_value, sur_value); |
6590 | } |
6591 | |
6592 | int CTv::GetBassUIMinGainVal() |
6593 | { |
6594 | return 0; |
6595 | } |
6596 | |
6597 | int CTv::GetBassUIMaxGainVal() |
6598 | { |
6599 | return 100; |
6600 | } |
6601 | |
6602 | int CTv::GetTrebleUIMinGainVal() |
6603 | { |
6604 | return 0; |
6605 | } |
6606 | |
6607 | int CTv::GetTrebleUIMaxGainVal() |
6608 | { |
6609 | return 100; |
6610 | } |
6611 | |
6612 | int CTv::MappingLine(int map_val, int src_min, int src_max, int dst_min, int dst_max) |
6613 | { |
6614 | if (dst_min < 0) { |
6615 | return (map_val - (src_max + src_min) / 2) * (dst_max - dst_min) |
6616 | / (src_max - src_min); |
6617 | } else { |
6618 | return (map_val - src_min) * (dst_max - dst_min) / (src_max - src_min); |
6619 | } |
6620 | } |
6621 | |
6622 | int CTv::MappingTrebleBassAndEqualizer(int tmp_vol, int direct, int tb_min, int tb_max) |
6623 | { |
6624 | int tmp_ret = 0; |
6625 | |
6626 | if (direct == 0) { |
6627 | tmp_ret = MappingLine(tmp_vol, tb_min, tb_max, CC_EQ_DEF_UI_MIN_GAIN, CC_EQ_DEF_UI_MAX_GAIN); |
6628 | } else { |
6629 | tmp_ret = MappingLine(tmp_vol, CC_EQ_DEF_UI_MIN_GAIN, CC_EQ_DEF_UI_MAX_GAIN, tb_min, tb_max); |
6630 | } |
6631 | |
6632 | LOGD("%s, tmp_vol = %d, direct = %d, tmp_ret = %d\n", __FUNCTION__, tmp_vol, |
6633 | direct, tmp_ret); |
6634 | |
6635 | return tmp_ret; |
6636 | } |
6637 | |
6638 | int CTv::MappingEQGain(int src_gain_buf[], int dst_gain_buf[], int direct) |
6639 | { |
6640 | int i = 0; |
6641 | int nMinUIVal = 0, nMaxUIVal = 0, nMinVal = 0, nMaxVal = 0; |
6642 | |
6643 | nMinUIVal = CC_EQ_DEF_UI_MIN_GAIN; |
6644 | nMaxUIVal = CC_EQ_DEF_UI_MAX_GAIN; |
6645 | nMinVal = CC_MIN_EQ_GAIN_VAL; |
6646 | nMaxVal = CC_MAX_EQ_GAIN_VAL; |
6647 | |
6648 | if (nMinUIVal >= nMinVal && nMaxUIVal <= nMaxVal) { |
6649 | for (i = 0; i < GetAudioEQBandCount(); i++) { |
6650 | dst_gain_buf[i] = src_gain_buf[i]; |
6651 | } |
6652 | } else { |
6653 | for (i = 0; i < GetAudioEQBandCount(); i++) { |
6654 | if (direct == 0) { |
6655 | dst_gain_buf[i] = MappingLine(src_gain_buf[i], nMinUIVal, |
6656 | nMaxUIVal, nMinVal, nMaxVal); |
6657 | } else { |
6658 | dst_gain_buf[i] = MappingLine(src_gain_buf[i], nMinVal, nMaxVal, |
6659 | nMinUIVal, nMaxUIVal); |
6660 | } |
6661 | } |
6662 | } |
6663 | return 0; |
6664 | } |
6665 | |
6666 | int CTv::RestoreToAudioDefEQGain(int gain_buf[]) |
6667 | { |
6668 | int i = 0; |
6669 | |
6670 | for (i = 0; i < GetAudioEQBandCount(); i++) { |
6671 | gain_buf[i] = (CC_EQ_DEF_UI_MAX_GAIN + CC_EQ_DEF_UI_MIN_GAIN) / 2; |
6672 | } |
6673 | |
6674 | ArrayCopy(mCurEQGainBuf, gain_buf, GetAudioEQBandCount()); |
6675 | ArrayCopy(mCurEQGainChBuf, gain_buf, GetAudioEQBandCount()); |
6676 | SSMSaveAudioEQGain(0, GetAudioEQBandCount(), mCurEQGainChBuf); |
6677 | |
6678 | HandleTrebleBassVolume(); |
6679 | SaveCurAudioSoundMode (CC_SOUND_MODE_STD); |
6680 | mCustomAudioSoundMode = mCurAudioSoundMode; |
6681 | return 0; |
6682 | } |
6683 | |
6684 | int CTv::GetCustomEQGain(int gain_buf[]) |
6685 | { |
6686 | ArrayCopy(gain_buf, mCustomEQGainBuf, GetAudioEQBandCount()); |
6687 | return 0; |
6688 | } |
6689 | |
6690 | int CTv::SetCustomEQGain() |
6691 | { |
6692 | int tmpEQGainBuf[128] = { 0 }; |
6693 | |
6694 | if (MappingEQGain(mCustomEQGainBuf, tmpEQGainBuf, 0) < 0) { |
6695 | return -1; |
6696 | } |
6697 | |
6698 | return RealSetEQGain(tmpEQGainBuf); |
6699 | } |
6700 | |
6701 | int CTv::AudioSetEQGain(int gain_buf[]) |
6702 | { |
6703 | int tmpEQGainBuf[128] = { 0 }; |
6704 | |
6705 | ArrayCopy(mCustomEQGainBuf, gain_buf, GetAudioEQBandCount()); |
6706 | |
6707 | if (MappingEQGain(mCustomEQGainBuf, tmpEQGainBuf, 0) < 0) { |
6708 | return -1; |
6709 | } |
6710 | |
6711 | return RealSetEQGain(tmpEQGainBuf); |
6712 | } |
6713 | |
6714 | int CTv::handleEQGainBeforeSet(int src_buf[], int dst_buf[]) |
6715 | { |
6716 | int i = 0, nMinGain, nMaxGain; |
6717 | |
6718 | nMinGain = CC_MIN_EQ_GAIN_VAL; |
6719 | nMaxGain = CC_MAX_EQ_GAIN_VAL; |
6720 | |
6721 | if (GetAudioWallEffect() == CC_SWITCH_ON && GetAudioWallEffectTypeCfg() == 0) { |
6722 | for (i = 0; i < GetAudioEQBandCount(); i++) { |
6723 | dst_buf[i] = mWallEffectValueBuf[i] + src_buf[i]; |
6724 | |
6725 | if (dst_buf[i] < nMinGain) { |
6726 | dst_buf[i] = nMinGain; |
6727 | } |
6728 | |
6729 | if (dst_buf[i] > nMaxGain) { |
6730 | dst_buf[i] = nMaxGain; |
6731 | } |
6732 | } |
6733 | } else { |
6734 | for (i = 0; i < GetAudioEQBandCount(); i++) { |
6735 | dst_buf[i] = src_buf[i]; |
6736 | } |
6737 | } |
6738 | |
6739 | return 0; |
6740 | } |
6741 | |
6742 | int CTv::RealSetEQGain(int gain_buf[]) |
6743 | { |
6744 | if (GetAudioWallEffect() == CC_SWITCH_ON && GetAudioWallEffectTypeCfg() == 0) { |
6745 | for (int i = 0; i < GetAudioEQBandCount(); i++) { |
6746 | gain_buf[i] = mWallEffectValueBuf[i] + gain_buf[i]; |
6747 | |
6748 | if (gain_buf[i] < CC_MIN_EQ_GAIN_VAL) { |
6749 | gain_buf[i] = CC_MIN_EQ_GAIN_VAL; |
6750 | } |
6751 | |
6752 | if (gain_buf[i] > CC_MAX_EQ_GAIN_VAL) { |
6753 | gain_buf[i] = CC_MAX_EQ_GAIN_VAL; |
6754 | } |
6755 | } |
6756 | } |
6757 | |
6758 | mAudioEffect.SetEQValue(gain_buf); |
6759 | return 0; |
6760 | } |
6761 | |
6762 | int CTv::SetAtvInGain(int gain_val) |
6763 | { |
6764 | char set_str[32] = {0}; |
6765 | |
6766 | sprintf ( set_str, "audio_gain_set %x", gain_val ); |
6767 | return SetFileAttrValue ( "/sys/class/amlatvdemod/atvdemod_debug", set_str ); |
6768 | } |
6769 | |
6770 | int CTv::SetSpecialModeEQGain(int tmp_val) |
6771 | { |
6772 | int tmpEQPresetBufPtr[24]; |
6773 | if (GetAudioEQPresetBufferPtr(tmpEQPresetBufPtr) != 0) { |
6774 | GetDefault_EQGain_Table(tmpEQPresetBufPtr); |
6775 | } |
6776 | int tmpEQGainBuf[128] = { 0 }; |
6777 | |
6778 | if (tmp_val == CC_SOUND_MODE_USER) { |
6779 | RealReadCurAudioEQGain(tmpEQGainBuf); |
6780 | } else { |
6781 | ArrayCopy(tmpEQGainBuf, |
6782 | tmpEQPresetBufPtr + tmp_val * GetAudioEQBandCount(), |
6783 | GetAudioEQBandCount()); |
6784 | } |
6785 | |
6786 | AudioSetEQGain(tmpEQGainBuf); |
6787 | return tmp_val; |
6788 | } |
6789 | |
6790 | int CTv::SetSpecialIndexEQGain(int buf_index, int w_val) |
6791 | { |
6792 | int tmpEQGainBuf[128] = { 0 }; |
6793 | |
6794 | if (buf_index >= 0 && buf_index < GetAudioEQBandCount()) { |
6795 | RealReadCurAudioEQGain(tmpEQGainBuf); |
6796 | tmpEQGainBuf[buf_index] = w_val; |
6797 | |
6798 | return AudioSetEQGain(tmpEQGainBuf); |
6799 | } |
6800 | return -1; |
6801 | } |
6802 | |
6803 | int CTv::SaveSpecialIndexEQGain(int buf_index, int w_val) |
6804 | { |
6805 | int tmpEQGainBuf[128] = { 0 }; |
6806 | |
6807 | if (buf_index >= 0 && buf_index < GetAudioEQBandCount()) { |
6808 | RealReadCurAudioEQGain(tmpEQGainBuf); |
6809 | tmpEQGainBuf[buf_index] = w_val; |
6810 | |
6811 | return RealSaveCurAudioEQGain(tmpEQGainBuf, 0); |
6812 | } |
6813 | |
6814 | return 0; |
6815 | } |
6816 | |
6817 | // amAudio |
6818 | int CTv::OpenAmAudio(unsigned int sr, int input_device, int output_device) |
6819 | { |
6820 | LOGD("OpenAmAudio input_device = %d", input_device); |
6821 | return amAudioOpen(sr, input_device, output_device); |
6822 | } |
6823 | |
6824 | int CTv::CloseAmAudio(void) |
6825 | { |
6826 | return amAudioClose(); |
6827 | } |
6828 | |
6829 | int CTv::SetAmAudioInputSr(unsigned int sr, int output_device) |
6830 | { |
6831 | LOGD("SetAmAudioInputSr "); |
6832 | return amAudioSetInputSr(sr, CC_IN_USE_SPDIF_DEVICE, output_device); |
6833 | } |
6834 | |
6835 | int CTv::SetAmAudioOutputMode(int mode) |
6836 | { |
6837 | if (mode != CC_AMAUDIO_OUT_MODE_DIRECT && mode != CC_AMAUDIO_OUT_MODE_INTER_MIX |
6838 | && mode != CC_AMAUDIO_OUT_MODE_DIRECT_MIX) { |
6839 | LOGE("%s, mode error, it should be mix or direct!\n", __FUNCTION__); |
6840 | return -1; |
6841 | } |
6842 | |
6843 | return amAudioSetOutputMode(mode); |
6844 | } |
6845 | |
6846 | int CTv::SetAmAudioMusicGain(int gain) |
6847 | { |
6848 | return amAudioSetMusicGain(gain); |
6849 | } |
6850 | |
6851 | int CTv::SetAmAudioLeftGain(int gain) |
6852 | { |
6853 | return amAudioSetLeftGain(gain); |
6854 | } |
6855 | |
6856 | int CTv::SetAmAudioRightGain(int gain) |
6857 | { |
6858 | return amAudioSetRightGain(gain); |
6859 | } |
6860 | |
6861 | int CTv::SetAudioDumpDataFlag(int tmp_flag) |
6862 | { |
6863 | return amAudioSetDumpDataFlag(tmp_flag); |
6864 | } |
6865 | |
6866 | int GetAudioDumpDataFlag() |
6867 | { |
6868 | return amAudioGetDumpDataFlag(); |
6869 | } |
6870 | |
6871 | static int RealCalVolDigitLUTBuf(int start_ind, int end_ind, int start_val, |
6872 | int end_val, int lut_buf[]) |
6873 | { |
6874 | int i = 0; |
6875 | float tmp_step = 0; |
6876 | |
6877 | if (end_ind < start_ind) { |
6878 | return 0; |
6879 | } |
6880 | |
6881 | tmp_step = (float) (end_val - start_val) / (float) (end_ind - start_ind); |
6882 | |
6883 | for (i = start_ind; i < end_ind; i++) { |
6884 | lut_buf[i] = start_val + (int) (tmp_step * (i - start_ind)); |
6885 | } |
6886 | |
6887 | lut_buf[end_ind] = end_val; |
6888 | return 1; |
6889 | } |
6890 | |
6891 | void CTv::AudioSetVolumeDigitLUTBuf(int lut_table_index, int *MainVolLutBuf) |
6892 | { |
6893 | int tmpDefDigitLutBuf[CC_LUT_BUF_SIZE] = { 0 }; |
6894 | mAudioAlsa.SetMainVolDigitLutBuf(MainVolLutBuf); |
6895 | |
6896 | GetAudioAmpSupbassvolBuf(lut_table_index, tmpDefDigitLutBuf); |
6897 | mAudioAlsa.SetSupperBassVolDigitLutBuf(tmpDefDigitLutBuf); |
6898 | } |
6899 | |
6900 | int CTv::InitTvAudio(int sr, int input_device) |
6901 | { |
6902 | OpenAmAudio(sr, input_device, CC_OUT_USE_AMAUDIO); |
6903 | |
6904 | RefreshSrsEffectAndDacGain(); |
6905 | SetCustomEQGain(); |
6906 | return 0; |
6907 | } |
6908 | |
6909 | int CTv::UnInitTvAudio() |
6910 | { |
6911 | return CloseAmAudio(); |
6912 | } |
6913 | |
6914 | int CTv::AudioChangeSampleRate(int sr) |
6915 | { |
6916 | sr = HanldeAudioInputSr(sr); |
6917 | |
6918 | if (SetAmAudioInputSr(sr, CC_OUT_USE_AMAUDIO) != 0) { |
6919 | return -1; |
6920 | } |
6921 | |
6922 | RefreshSrsEffectAndDacGain(); |
6923 | SetCustomEQGain(); |
6924 | return 0; |
6925 | } |
6926 | |
6927 | int CTv::AudioSetAudioInSource(int audio_src_in_type) |
6928 | { |
6929 | return mAudioAlsa.SetAudioInSource(audio_src_in_type); |
6930 | } |
6931 | |
6932 | int CTv::AudioSetAudioSourceType(int source_type) |
6933 | { |
6934 | int aud_arch_type = GetAudioArchitectureTypeCFG(); |
6935 | |
6936 | if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_ON_BOARD) { |
6937 | } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { |
6938 | SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_SOURCE, source_type); |
6939 | } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_CUSTOMER_LIB) { |
6940 | mCustomerCtrl.SetSource(source_type); |
6941 | } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_DIGITAL) { |
6942 | } |
6943 | return 0; |
6944 | } |
6945 | |
6946 | int CTv::AudioLineInSelectChannel(int audio_channel) |
6947 | { |
6948 | LOGD ("%s, audio_channel = %d", __FUNCTION__, audio_channel); |
6949 | mAudioAlsa.SetInternalDacLineInSelectChannel(audio_channel); |
6950 | return 0; |
6951 | } |
6952 | |
6953 | int CTv::SetKalaokIO(int level) |
6954 | { |
6955 | LOGD ("%s, SetKalaokIO = %d", __FUNCTION__, level); |
6956 | if (GetKaraokAvEnable() == 1) { |
6957 | mAudioAlsa.SetAudioSwitchIO(level); |
6958 | } |
6959 | return 0; |
6960 | } |
6961 | |
6962 | int CTv::AudioSetLineInCaptureVolume(int l_vol, int r_vol) |
6963 | { |
6964 | mAudioAlsa.SetInternalDacLineInCaptureVolume(l_vol, r_vol); |
6965 | return 0; |
6966 | } |
6967 | |
6968 | int CTv::openTvAudio() |
6969 | { |
6970 | int tmp_val = 0; |
6971 | |
6972 | LOGD("%s, entering...\n", __FUNCTION__); |
6973 | UnInitSetTvAudioCard(); |
6974 | |
6975 | tmp_val = GetAudioDumpDataEnableFlagCfg(); |
6976 | SetAudioDumpDataFlag(tmp_val); |
6977 | |
6978 | tmp_val = GetAudioInternalDacPGAInGain_Cfg(); |
6979 | mAudioAlsa.SetAudioInternalDacPGAInGain(tmp_val, tmp_val); |
6980 | |
6981 | mAudioAlsa.SetMixerBypassSwitch (CC_SWITCH_OFF); |
6982 | mAudioAlsa.SetMixerDacSwitch (CC_SWITCH_ON); |
6983 | |
6984 | LoadAudioCtl(); |
6985 | |
6986 | RefreshSrsEffectAndDacGain(); |
6987 | InitSetAudioCtl(); |
6988 | return 0; |
6989 | } |
6990 | |
6991 | int CTv::closeTvAudio() |
6992 | { |
6993 | return 0; |
6994 | } |
6995 | |
6996 | void CTv::LoadAudioCtl() |
6997 | { |
6998 | // Get Current Audio Volume |
6999 | LoadCurAudioMasterVolume(); |
7000 | |
7001 | // Get Current Audio Balance |
7002 | LoadCurAudioBalance(); |
7003 | |
7004 | // Get Current Supper Bass Switch |
7005 | LoadCurAudioSupperBassSwitch(); |
7006 | |
7007 | // Get Current Supper Bass Volume |
7008 | LoadCurAudioSupperBassVolume(); |
7009 | |
7010 | // Get Current SRSSurround |
7011 | LoadCurAudioSrsSurround(); |
7012 | |
7013 | // Get Current SRS DialogClarity |
7014 | LoadCurAudioSrsDialogClarity(); |
7015 | |
7016 | // Get Current SRS TruBass |
7017 | LoadCurAudioSrsTruBass(); |
7018 | |
7019 | // Get Current Audio Sound Mode |
7020 | LoadCurAudioSoundMode(); |
7021 | |
7022 | // Get Current Audio Bass and Treble |
7023 | LoadCurAudioBassVolume(); |
7024 | LoadCurAudioTrebleVolume(); |
7025 | |
7026 | // Get Current Wall Effect |
7027 | LoadCurAudioWallEffect(); |
7028 | |
7029 | // Get Current spdif switch |
7030 | LoadCurAudioSPDIFSwitch(); |
7031 | |
7032 | // Get Current spdif mode |
7033 | LoadCurAudioSPDIFMode(); |
7034 | |
7035 | // Get Current EQ mode |
7036 | LoadCurAudioEQMode(); |
7037 | |
7038 | // Get Current EQ Gain |
7039 | LoadCurAudioEQGain(); |
7040 | } |
7041 | |
7042 | void CTv::InitSetAudioCtl() |
7043 | { |
7044 | // Set Current Audio balance value |
7045 | SetAudioBalance(GetAudioBalance()); |
7046 | |
7047 | // Set Current Audio Volume |
7048 | SetAudioMasterVolume(GetAudioMasterVolume()); |
7049 | |
7050 | // Set Current Supper Bass Volume |
7051 | SetAudioSupperBassVolume(GetAudioSupperBassVolume()); |
7052 | |
7053 | // Set Current Audio Sound Mode |
7054 | SetAudioSoundMode(GetAudioSoundMode()); |
7055 | |
7056 | // Set Current Audio SPDIF Switch |
7057 | SetAudioSPDIFSwitch(GetCurAudioSPDIFSwitch()); |
7058 | |
7059 | // Set Current Audio SPDIF mode |
7060 | SetAudioSPDIFMode(GetCurAudioSPDIFMode()); |
7061 | } |
7062 | |
7063 | int CTv::SetADC_Digital_Capture_Volume(int value) |
7064 | { |
7065 | return mAudioAlsa.SetAudioInternalDacADCDigitalCaptureVolume( value, value); |
7066 | } |
7067 | |
7068 | int CTv::SetPGA_IN_Value(int value) |
7069 | { |
7070 | return mAudioAlsa.SetAudioInternalDacPGAInGain( value, value); |
7071 | } |
7072 | |
7073 | int CTv::SetDAC_Digital_PlayBack_Volume(int value) |
7074 | { |
7075 | return mAudioAlsa.SetAudioInternalDacDACDigitalPlayBackVolume( value, value); |
7076 | } |
7077 | |
7078 | int CTv::setAudioPcmPlaybackVolume(int val) |
7079 | { |
7080 | int pcm_volume = 0; |
7081 | pcm_volume = val / 2; |
7082 | if (pcm_volume > 24) pcm_volume = 24; |
7083 | //return SetAudioPcmPlaybackVolume(pcm_volume); |
7084 | return 0; |
7085 | } |
7086 | |
7087 | int CTv::HanldeAudioInputSr(unsigned int sr) |
7088 | { |
7089 | int tmp_cfg = 0; |
7090 | |
7091 | tmp_cfg = GetAudioResampleTypeCFG(); |
7092 | if (tmp_cfg & CC_AUD_RESAMPLE_TYPE_HW) { |
7093 | mAudioAlsa.SetHardwareResample(sr); |
7094 | } else { |
7095 | mAudioAlsa.SetHardwareResample(-1); |
7096 | } |
7097 | |
7098 | if (!(tmp_cfg & CC_AUD_RESAMPLE_TYPE_SW)) { |
7099 | sr = 48000; |
7100 | } |
7101 | |
7102 | return sr; |
7103 | } |
7104 | |
7105 | int CTv::AudioSSMRestoreDefaultSetting() |
7106 | { |
7107 | int i = 0, tmp_val = 0; |
7108 | int nMinUIVol = 0, nMaxUIVol = 0; |
7109 | int *tmp_ptr = NULL; |
7110 | int tmpEQGainBuf[128] = { 0 }; |
7111 | unsigned char tmp_buf[CC_NO_LINE_POINTS_MAX_CNT] = { 0 }; |
7112 | |
7113 | // Save Current Audio Volume |
7114 | SaveCurAudioMasterVolume (CC_DEF_SOUND_VOL); |
7115 | |
7116 | // Save Current Audio Balance |
7117 | SaveCurAudioBalance (CC_DEF_SOUND_BALANCE_VAL); |
7118 | |
7119 | // Save Current Supper Bass Switch |
7120 | SaveCurAudioSupperBassSwitch (CC_SWITCH_OFF); |
7121 | |
7122 | // Save Current Supper Bass Volume |
7123 | SaveCurAudioSupperBassVolume (CC_DEF_SUPPERBASS_VOL); |
7124 | |
7125 | // Save Current SRSSurround |
7126 | SaveCurAudioSrsSurround(CC_SWITCH_OFF); |
7127 | |
7128 | // Save Current SRS DialogClarity |
7129 | SaveCurAudioSrsDialogClarity(CC_SWITCH_OFF); |
7130 | |
7131 | // Save Current SRS TruBass |
7132 | SaveCurAudioSrsTruBass(CC_SWITCH_OFF); |
7133 | |
7134 | // Save Current Audio Sound Mode |
7135 | SaveCurAudioSoundMode (CC_SOUND_MODE_STD); |
7136 | |
7137 | // Save Current Wall Effect |
7138 | SaveCurAudioWallEffect(CC_SWITCH_OFF); |
7139 | |
7140 | // Save Current spdif switch |
7141 | SaveCurAudioSPDIFSwitch (CC_SWITCH_ON); |
7142 | |
7143 | // Save Current spdif mode |
7144 | SaveCurAudioSPDIFMode (CC_SPDIF_MODE_PCM); |
7145 | |
7146 | // Save Current avout and spidif mute state |
7147 | SSMSaveAudioSPIDFMuteVal(CC_AUDIO_MUTE); |
7148 | SSMSaveAudioAVOutMuteVal(CC_AUDIO_MUTE); |
7149 | |
7150 | // Save Current EQ mode |
7151 | SaveCurAudioEQMode (CC_EQ_MODE_NOMAL); |
7152 | |
7153 | // Save Current EQ Gain |
7154 | RestoreToAudioDefEQGain(tmpEQGainBuf); |
7155 | |
7156 | // Save Current Audio Bass and Treble |
7157 | nMinUIVol = GetBassUIMinGainVal(); |
7158 | nMaxUIVol = GetBassUIMaxGainVal(); |
7159 | RealSaveCurAudioBassVolume((nMinUIVol + nMaxUIVol) / 2, 0); |
7160 | |
7161 | nMinUIVol = GetTrebleUIMinGainVal(); |
7162 | nMaxUIVol = GetTrebleUIMaxGainVal(); |
7163 | RealSaveCurAudioTrebleVolume((nMinUIVol + nMaxUIVol) / 2, 0); |
7164 | return 0; |
7165 | } |
7166 | |
7167 | static const char *gDefCapturePropName = "snd.card.default.card.capture"; |
7168 | |
7169 | int CTv::InitSetTvAudioCard() |
7170 | { |
7171 | int i = 0, totle_num = 0, capture_ind = 0; |
7172 | char tmp_buf[32] = { 0 }; |
7173 | char tv_card_name[64] = { 0 }; |
7174 | char prop_value[PROPERTY_VALUE_MAX]; |
7175 | |
7176 | #ifndef BOARD_ALSA_AUDIO_TINY |
7177 | snd_card_refresh_info(); |
7178 | #endif |
7179 | |
7180 | if (GetTvAudioCardNeedSet()) { |
7181 | memset(prop_value, '\0', PROPERTY_VALUE_MAX); |
7182 | property_get("snd.card.totle.num", prop_value, "0"); |
7183 | |
7184 | totle_num = strtoul(prop_value, NULL, 10); |
7185 | LOGD("%s, totle number = %d\n", __FUNCTION__, totle_num); |
7186 | totle_num = 8; |
7187 | |
7188 | GetTvAudioCardName(tv_card_name); |
7189 | |
7190 | for (i = 0; i < totle_num; i++) { |
7191 | sprintf(tmp_buf, "snd.card.%d.name", i); |
7192 | memset(prop_value, '\0', PROPERTY_VALUE_MAX); |
7193 | property_get(tmp_buf, prop_value, "null"); |
7194 | |
7195 | LOGD("%s, key string \"%s\", value string \"%s\".\n", __FUNCTION__, tmp_buf, prop_value); |
7196 | |
7197 | if (strcmp(prop_value, tv_card_name) == 0) { |
7198 | break; |
7199 | } |
7200 | } |
7201 | |
7202 | capture_ind = i; |
7203 | |
7204 | if (capture_ind == totle_num) { |
7205 | capture_ind = -1; |
7206 | LOGE("%s, can't find tv card \"%s\".\n", __FUNCTION__, tv_card_name); |
7207 | } |
7208 | } else { |
7209 | capture_ind = -1; |
7210 | } |
7211 | |
7212 | sprintf(tmp_buf, "%d", capture_ind); |
7213 | property_set(gDefCapturePropName, tmp_buf); |
7214 | LOGD("%s, set \"%s\" as \"%s\".\n", __FUNCTION__, gDefCapturePropName, tmp_buf); |
7215 | return 0; |
7216 | } |
7217 | |
7218 | int CTv::UnInitSetTvAudioCard() |
7219 | { |
7220 | char tmp_buf[32] = { 0 }; |
7221 | |
7222 | #ifndef BOARD_ALSA_AUDIO_TINY |
7223 | snd_card_refresh_info(); |
7224 | #endif |
7225 | sprintf(tmp_buf, "%d", -1); |
7226 | property_set(gDefCapturePropName, tmp_buf); |
7227 | LOGD("%s, set \"%s\" as \"%s\".\n", __FUNCTION__, gDefCapturePropName, tmp_buf); |
7228 | return 0; |
7229 | } |
7230 | |
7231 | #define CS_SPDIF_MODE_DEV_PATH "/sys/class/audiodsp/digital_raw" |
7232 | |
7233 | int CTv::SetSPDIFMode(int mode_val) |
7234 | { |
7235 | FILE *spdif_mode_fp = NULL; |
7236 | |
7237 | spdif_mode_fp = fopen(CS_SPDIF_MODE_DEV_PATH, "w"); |
7238 | if (spdif_mode_fp == NULL) { |
7239 | LOGE("%s, Open file %s error(%s)!\n", __FUNCTION__, CS_SPDIF_MODE_DEV_PATH, strerror(errno)); |
7240 | return -1; |
7241 | } |
7242 | |
7243 | if (mode_val == CC_SPDIF_MODE_PCM) { |
7244 | fprintf(spdif_mode_fp, "%d", 0); |
7245 | } else if (mode_val == CC_SPDIF_MODE_RAW ) { |
7246 | fprintf(spdif_mode_fp, "%d", 1); |
7247 | } |
7248 | |
7249 | fclose(spdif_mode_fp); |
7250 | spdif_mode_fp = NULL; |
7251 | |
7252 | return 0; |
7253 | } |
7254 | |
7255 | int CTv::SwitchAVOutBypass(int sw) |
7256 | { |
7257 | if (sw == 0 ) { |
7258 | mAudioAlsa.SetMixerBypassSwitch ( CC_SWITCH_OFF ); |
7259 | mAudioAlsa.SetMixerDacSwitch ( CC_SWITCH_ON ); |
7260 | } else { |
7261 | mAudioAlsa.SetMixerBypassSwitch ( CC_SWITCH_ON ); |
7262 | mAudioAlsa.SetMixerDacSwitch ( CC_SWITCH_OFF ); |
7263 | } |
7264 | return 0; |
7265 | } |
7266 | |
7267 | int CTv::SetAudioSwitchIO(int value) |
7268 | { |
7269 | return mAudioAlsa.SetAudioSwitchIO( value); |
7270 | } |
7271 | |
7272 | int CTv::SetOutput_Swap(int value) |
7273 | { |
7274 | return mAudioAlsa.SetOutput_Swap( value); |
7275 | } |
7276 | |
7277 | int CTv::SendCmdToOffBoardFBCExternalDac(int cmd, int para) |
7278 | { |
7279 | int set_val = 0; |
7280 | CFbcCommunication *pFBC = GetSingletonFBC(); |
7281 | if (pFBC != NULL) { |
7282 | if (cmd == AUDIO_CMD_SET_MUTE) { |
7283 | if (para == CC_AUDIO_MUTE) { |
7284 | set_val = CC_MUTE_ON; |
7285 | } else if (para == CC_AUDIO_UNMUTE) { |
7286 | set_val = CC_MUTE_OFF; |
7287 | } else { |
7288 | return -1; |
7289 | } |
7290 | |
7291 | return pFBC->cfbc_Set_Mute(COMM_DEV_SERIAL, set_val); |
7292 | } else if (cmd == AUDIO_CMD_SET_VOLUME_BAR) { |
7293 | LOGD("%s, send AUDIO_CMD_SET_VOLUME_BAR (para = %d) to fbc.\n", __FUNCTION__, para); |
7294 | return pFBC->cfbc_Set_Volume_Bar(COMM_DEV_SERIAL, para); |
7295 | } else if (cmd == AUDIO_CMD_SET_BALANCE) { |
7296 | LOGD("%s, send AUDIO_CMD_SET_BALANCE (para = %d) to fbc.\n", __FUNCTION__, para); |
7297 | return pFBC->cfbc_Set_Balance(COMM_DEV_SERIAL, para); |
7298 | } else if (cmd == AUDIO_CMD_SET_SOURCE) { |
7299 | LOGD("%s, send AUDIO_CMD_SET_SOURCE (para = %d) to fbc.\n", __FUNCTION__, para); |
7300 | return pFBC->cfbc_Set_FBC_Audio_Source(COMM_DEV_SERIAL, para); |
7301 | } |
7302 | } |
7303 | return 0; |
7304 | } |
7305 | |
7306 | int CTv::GetHdmiAvHotplugDetectOnoff() |
7307 | { |
7308 | const char *value = config_get_str ( CFG_SECTION_TV, "ssm.hdmi_av.hotplug.detect.en", "null" ); |
7309 | if ( strtoul(value, NULL, 10) == 1 ) { |
7310 | return 1; |
7311 | } |
7312 | |
7313 | return 0; |
7314 | } |
7315 | |
7316 |