/****************************************************************************** *_Copyright (c) 2009 Digital Stream Technology Inc. All Rights Reserved. * * Module: dstddcap.c * * Description * Platform/Vendor specific functions for external audio/video inputs. * * @author * @version $Revision: 1.1 $ * ******************************************************************************/ #include #include #include #include #include #include #include #include #include "dsthalcommon.h" #include "dsthallocal.h" #include "dstdddtv.h" #include "dstddcap.h" #include "dstdddisp.h" #include "dstdddmx.h" #include "dstddsys.h" #ifdef DMALLOC #include #endif /****************************************************************************** * Global variable declaration ******************************************************************************/ DS_U32 gddCapDbgLvl = 1; //DHL_CAP debug level DS_U32 gVideoStartTimestamp = 0; int gHDMIDelay = 500; int g_UsePerade321 = 0; // default not used. int g_CCResetTimeout = 500; /****************************************************************************** * Imported variable declaration ******************************************************************************/ /****************************************************************************** * Imported function declaration ******************************************************************************/ /****************************************************************************** * Local definitions ******************************************************************************/ /****************************************************************************** * Local typedefs ******************************************************************************/ #if 0 typedef struct { unsigned char type; unsigned char version; unsigned char length; unsigned char pb_byte[28]; } infoframe_struct; typedef struct { BYTE packets_need_config; //which infoframe packet is need updated infoframe_struct avi_info; infoframe_struct audio_info; infoframe_struct spd_info; infoframe_struct mpeg_info; infoframe_struct acp_pkt; infoframe_struct isrc1_pkt; infoframe_struct isrc2_pkt; infoframe_struct vendor_info; } config_packets; #endif /****************************************************************************** * Local variables declaration ******************************************************************************/ DS_U16 g_CVBS_SN = 0; VGA_CAPTURE_t curVGACapture; static int m_VGAHSize, m_VGAVSize; static int m_VGAHPosition, m_VGAVPosition; static int m_VGAPhase, m_VGAClock; static int m_VGACaptureValid = 0; /****************************************************************************** * Local function prototypes ******************************************************************************/ static void DD_CAP_BeforeSourceChange(DHL_CAP_VIDEO_INPUT vSrc); static void DD_CAP_AfterSourceChange(DHL_CAP_VIDEO_INPUT vSrc); static void DD_CAP_SetPCLKSSC(DHL_CAP_VIDEO_INPUT vMainSrc); void cbSetHPD(int Delay); DHL_RESULT DD_CAP_SelectAudioInput( DHL_CAP_AUDIO_INPUT audIn ); #if 0 ___Common_Functions___() #endif DHL_RESULT DD_CAP_Init(void) { DHL_RESULT dhlResult = DHL_OK; return dhlResult; } DHL_RESULT DD_CAP_Close(void) { DHL_RESULT dhlResult = DHL_OK; return dhlResult; } DHL_RESULT DD_CAP_Pause(DS_BOOL Focus) { DHL_RESULT dhlResult = DHL_OK; dhlResult = DD_CAP_VideoPause(Focus); return dhlResult; } DHL_RESULT DD_CAP_Resume(DS_BOOL Focus) { DHL_RESULT dhlResult = DHL_OK; dhlResult = DD_CAP_VideoResume(Focus); return dhlResult; } #if 0 ___Video_Functions___() #endif DHL_RESULT DD_CAP_StartVideo(void) { DHL_RESULT dhlResult = DHL_OK; DHL_CAP_VIDEO_INPUT vSrc; // // Video Source should be applied before calling this API, // so that DHL_CAP_GetVideoSrc() return new source correctly. // vSrc = DHL_CAP_GetVideoSrc(0/*0:Main*/); DD_CAP_BeforeSourceChange( vSrc ); // // Call the vendor-supplied MPSource change API here. // DD_CAP_SetSyncLock(1); DD_CAP_SetPCLKSSC( vSrc ); DD_CAP_AfterSourceChange( vSrc ); // // Save Video-Start timestamp. // gVideoStartTimestamp = OS_GetTickCount(); return dhlResult; } DHL_RESULT DD_CAP_StopVideo(void) { DHL_RESULT dhlResult = DHL_OK; DD_CAP_SetSyncLock(0); return dhlResult; } DHL_RESULT DD_CAP_StartVideoPIP(void) { DHL_RESULT dhlResult = DHL_OK; DHL_CAP_VIDEO_INPUT vSrc; vSrc = DHL_CAP_GetVideoSrc(1/*1:Sub*/); DD_CAP_BeforeSourceChange( vSrc ); // // Call the vendor-supplied VIDEO-START for SubWindow API here. // DD_CAP_AfterSourceChange( vSrc ); return dhlResult; } DHL_RESULT DD_CAP_StopVideoPIP(void) { DHL_RESULT dhlResult = DHL_OK; // // Call the vendor-supplied VIDEO-STOP for SubWindow API here. // return dhlResult; } DHL_RESULT DD_CAP_SelectVideoInput( DHL_CAP_VIDEO_INPUT audIn, DS_BOOL bFocus ) { DHL_RESULT dhlResult = DHL_OK; return dhlResult; } DHL_RESULT DD_CAP_ChangeVideoFormat(DHL_VIDEO_FORMAT UserVideoFormat, DS_BOOL Update, DS_BOOL Focus) { DHL_RESULT dhlResult = DHL_OK; return dhlResult; } DHL_RESULT DD_CAP_VideoPause(DS_BOOL Focus) { DHL_RESULT dhlResult = DHL_OK; return dhlResult; } DHL_RESULT DD_CAP_VideoResume(DS_BOOL Focus) { DHL_RESULT dhlResult = DHL_OK; return dhlResult; } DHL_RESULT DD_CAP_GetVideoTiming(DS_BOOL bFocus, DS_U16 *phRes, DS_U16 *pvRes, DS_U16 *pRefreshRate, DS_BOOL *pbInterlaced) { DHL_RESULT dhlResult = DHL_OK; return dhlResult; } DS_BOOL DD_CAP_IsSrcChangeValid(DS_BOOL bFocus) { return _TRUE_; } DS_BOOL DD_CAP_IsInputSrcValid(DS_BOOL bFocus) { return _TRUE_; } DHL_RESULT DD_CAP_IsHDMIMode(DS_BOOL *bHDMI) { *bHDMI = 0; return DHL_OK; } void DD_CAP_SetSyncLock(int bEnable) { } void DD_CAP_SetSyncLockEnable(int bEnable) { } void DD_CAP_ClearSyncLock(void) { } void DD_CAP_ClearSyncLockOnMute(int En) { } DS_U16 DD_CAP_GetSignalNoise(void) { return g_CVBS_SN; } DS_U16 DD_CAP_GetFieldMotion(void) { return 0; } DS_U16 DD_CAP_GetFrameMotion(void) { return 0; } void DD_CAP_SetMotionThreshold(DS_U16 threshold) { } // // DD_CAP_SetAdaptiveNR // // Set adaptive NR // // 63 ~ 49 dBuV (SN: 0~3) Low Filter // 48 ~ 39 dBuV (SN: 4~8) Median Filter // 38 ~ 0 dBuV (SN: 9~) High Filter // static int g_NTSCAdaptiveNR = 1; void DD_CAP_SetAdaptiveNR(void) { static DS_U16 oldSignalNoise[3] = { 0xFFFF, 0xFFFF, 0xFFFF }; DS_U16 signalNoise; if ( g_NTSCAdaptiveNR == 0 ) return; signalNoise = DD_CAP_GetSignalNoise(); if (signalNoise == oldSignalNoise[0]) return; oldSignalNoise[2] = oldSignalNoise[1]; oldSignalNoise[1] = oldSignalNoise[0]; oldSignalNoise[0] = signalNoise; signalNoise = oldSignalNoise[0]; signalNoise += oldSignalNoise[1]; signalNoise += oldSignalNoise[2]; signalNoise /= 3; if (g_NTSCAdaptiveNR>=2) printf("signalNoise=%d\n", signalNoise); // // Apply post-processing, such as Noise reduction function, based on the signalNoise variable. // } void DD_CAP_GetHDMIFmt(DS_U32 *phPix, DS_U32 *phTotal, DS_U32 *pvLine, DS_U32 *pvTotal) { } int DD_CAP_GetGamutDataCallback(char *buf, int reason, char data) { // // Do Gamut data callback... // return 1; } void DD_CAP_GetRGBFmt(DS_U16 *pwHR, DS_U16 *pwVR, DS_U16 *pwHW, DS_U16 *pwVW, DS_U16 *pwPol) { } #if 0 ___VBI_Functions___() #endif void DD_CAP_ResetVBI(DS_BOOL bFocus) { } static int FeedTestString = 0; static DS_U8 strTest608[256]; DHL_RESULT DD_CAP_GetVBI(DS_BOOL bFocus, DS_U8 *pBuf, int *pLen) { DHL_RESULT dhlResult = DHL_OK; static DS_U32 lastSent = 0; static int cnt = 0; int i, j; switch (FeedTestString) { case 1: { if ( (OS_GetTickCount()-lastSent) < 100 ) { *pLen = 0; return dhlResult; } i=0; pBuf[i++] = 1; pBuf[i++] = 0x14; pBuf[i++] = 0x2B; /* Text Mode */ pBuf[i++] = 1; pBuf[i++] = 0x11; pBuf[i++] = 0x20 + (cnt%16); sprintf((char *)strTest608, "608CC string %d (c:%d)", cnt, (cnt%16)); for (j=0; j %d\n", FeedTestString, mode ); FeedTestString = mode; }