📄 cne2000.c
字号:
QRESULT qRes = Q_OK; if( this->m_pINova1 == NULL ) return E_NOT_SUPPORTED; IAnalogOverlay_StartAutoCalibration(this->m_pINova1); IDecoder_VideoWriteCommand(this->m_pIDecoder, VIDEO_BLACKFRAME_UNPACKED); // fix color calib for 1600 resolution (it should be fixed in mcifmp = draw the colors close to left) if(this->DisplayResolution.iScreenWidth > 1300) IDecoder_UpdateMpegDICOM(this->m_pIDecoder, 0, 0, Width, Height, this->XOffset, this->YOffset, this->Correction, this->IsInterlaced); else IDecoder_UpdateMpegDICOM(this->m_pIDecoder, 0, 0, 2*Width, Height, this->XOffset, this->YOffset, this->Correction, this->IsInterlaced); OSTimeDelay(DICOM_UPDATE_TIME);// mcifmp32 - calwnd.cpp - OnCalibrate() :// - it draws on VGA one central white bar over black// - it calls this procedure with Mask=0x81 for lower values and Mask=0x80 for upper values// - it draws on VGA one central grey bar over black// - it calls this procedure with Mask=0x83 for lower values and Mask=0x82 for upper values// - it draws on VGA onlyblack// - it calls this procedure with Mask=0x85 for lower values and Mask=0x84 for upper values switch(pIn->Mask) { case 0x80: // WHITE upper case 0x81: // WHITE lower if(!IAnalogOverlay_UpperLower(this->m_pINova1, 0xFF, pOut)) qRes = E_NOVA_AUTOCALIB_FAILED; break; case 0x82: // GREY upper case 0x83: // GREY lower if(!IAnalogOverlay_UpperLower(this->m_pINova1, 0x80, pOut)) qRes = E_NOVA_AUTOCALIB_FAILED; break; case 0x84: // BLACK upper case 0x85: // BLACK lower // the detection for black is not working - Nova will return some defaults if(!IAnalogOverlay_UpperLower(this->m_pINova1, 0x20, pOut)) qRes = E_NOVA_AUTOCALIB_FAILED; } IAnalogOverlay_StopAutoCalibration(this->m_pINova1); QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("RGB_AutoCalibration%x Red = %02x_%02x Green = %02x_%02x Blue = %02x_%02x"), pIn->Mask, pOut->RedUpper, pOut->RedLower, pOut->GreenUpper, pOut->GreenLower, pOut->BlueUpper, pOut->BlueLower)); return qRes;}/****f* HwLib/IDecoderBoard_OverlayCalibrate * USAGE * QRESULT IDecoderBoard_OverlayCalibrate(IDecoderBoard* pIDecoderBoard, POVERLAY_COLOUR_REGISTERS pIn, POVERLAY_COLOUR_REGISTERS pOut) * QRESULT CNE2000__OverlayCalibrate(IDecoderBoard* pIDecoderBoard, POVERLAY_COLOUR_REGISTERS pIn, POVERLAY_COLOUR_REGISTERS pOut) * DESCRIPTION * IDecoderBoard_OverlayCalibrate: * if pIn->Mask 0x80 ... 0x85 calls IDecoderBoard_OverlayColorCalibrate * if pIn->Mask = 0x88 calls IDecoderBoard_AdjTopBorder and YOffset is returned in pOut->RedLower * if pIn->Mask = 0x89 calls IDecoderBoard_AdjLeftBorder and XOffset is returned in pOut->RedLower * if pIn->Mask = 0x8a calls IDecoderBoard_AdjCorrection and Correction is returned in pOut->RedLower * if pIn->Mask != 0xFFFF the values from pIn serve for color key - for manual calibration * PARAMETERS * IN IDecoderBoard* pIDecoderBoard - pointer to the board object * IN POVERLAY_COLOUR_REGISTERS pIn * OUT POVERLAY_COLOUR_REGISTERS pOut * RETURN VALUE * Q_OK, E_INVALID_PARAMETER, E_NOT_SUPPORTED if Analog overlay is not present * SEE ALSO * IDecoderBoard_OverlayColorCalibrate, IDecoderBoard_AdjTopBorder, * IDecoderBoard_AdjLeftBorder, IDecoderBoard_AdjCorrection/*****************************************************************************/QRESULT CNE2000__OverlayCalibrate(IDecoderBoard* pIDecoderBoard, POVERLAY_COLOUR_REGISTERS pIn, POVERLAY_COLOUR_REGISTERS pOut){ CQuasarBoard *this = (CQuasarBoard*) pIDecoderBoard; if( this->m_pINova1 == NULL ) return E_NOT_SUPPORTED; if(pIn->Mask == 0xffff) return Q_OK; if ( (pIn->Mask >= 0x80) && (pIn->Mask <= 0x85) ) { return CNE2000__OverlayColorCalibrate(pIDecoderBoard, pIn, pOut); } if(pIn->Mask == 0x88) { QRESULT qr = CNE2000__AdjTopBorder(pIDecoderBoard, &pOut->RedLower); this->YOffset = pOut->RedLower; return qr; } else if(pIn->Mask == 0x89) { QRESULT qr = CNE2000__AdjLeftBorder(pIDecoderBoard, &pOut->RedLower); this->XOffset = pOut->RedLower; return qr; } else if(pIn->Mask == 0x8a) { QRESULT qr = CNE2000__AdjCorrection(pIDecoderBoard, this->XOffset, (DWORD*)&pOut->RedLower); this->Correction = pOut->RedLower; return qr; } else { QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("OverlayHwCalibrate Mask=%x RU=%x RL=%x GU=%x GL=%x BU=%x BL=%x"), pIn->Mask, pIn->RedUpper,pIn->RedLower, pIn->GreenUpper, pIn->GreenLower, pIn->BlueUpper, pIn->BlueLower)); pIn->Mask = (pIn->Mask & 0x0022) | ((pIn->Mask & 0x0011)<<2) | ((pIn->Mask & 0x0044)>>2); IAnalogOverlay_SetChromaKey(this->m_pINova1, (pIn->RedUpper & 0xff) | ((pIn->GreenUpper & 0xff)<<8) | ((pIn->BlueUpper & 0xff)<<16), (pIn->RedLower & 0xff) | ((pIn->GreenLower & 0xff)<<8) | ((pIn->BlueLower & 0xff)<<16), pIn->Mask); } return Q_OK;}void CNE2000Common__InitVtable(IDecoderBoard* pIDecoderBoard){ CQuasarBoard* this = (CQuasarBoard*) pIDecoderBoard; this->lpVtbl->HwReset = CNE2000__HwReset; this->lpVtbl->UpdateOverlay = CNE2000__UpdateOverlay; this->lpVtbl->VidChangeDisplayResolution= CNE2000__VidChangeDisplayResolution; this->lpVtbl->SetCustomTvHdtv = CNE2000__SetCustomTvHdtv; this->lpVtbl->OverlaySetVgaKey = CNE2000__OverlaySetVgaKey; this->lpVtbl->OverlayGetVgaKey = CNE2000__OverlayGetVgaKey; this->lpVtbl->OverlaySetVgaKey2 = CNE2000__OverlaySetVgaKey2; this->lpVtbl->OverlayGetVgaKey2 = CNE2000__OverlayGetVgaKey2; this->lpVtbl->OverlaySetMode = CNE2000__OverlaySetMode; this->lpVtbl->OverlayCalibrate = CNE2000__OverlayCalibrate; this->lpVtbl->OverlaySetColorCalibration= CNE2000__OverlaySetColorCalibration; this->lpVtbl->AdjTopBorder = CNE2000__AdjTopBorder; this->lpVtbl->AdjLeftBorder = CNE2000__AdjLeftBorder; this->lpVtbl->AdjCorrection = CNE2000__AdjCorrection; this->lpVtbl->OverlayColorCalibrate = CNE2000__OverlayColorCalibrate;}QRESULT CNE2000Common__SpecificCreateInstance(IDecoderBoard* pIDecoderBoard, DWORD dwInstance){ CQuasarBoard* this = (CQuasarBoard*) pIDecoderBoard; DWORD pio2; this->BoardCapabilities |= ( MPEG_CAPABILITY_VGATV_SWITCH_BUTTON | MPEG_CAPABILITY_TV_YUV_COMPONENT | MPEG_CAPABILITY_TV_RGB_COMPONENT | MPEG_CAPABILITY_HDTV_OUTPUT ); // Create CNova instance if( ModCreateInstance (dwInstance, &CLSID_CNOVA, &IID_IANALOGOVERLAY, (void**)&this->m_pINova1) != NOERROR ) { return Q_FAIL; } IAnalogOverlay_Init(this->m_pINova1, NULL); IAnalogOverlay_SetRegistry(this->m_pINova1, this->pRegistry); if ( IAnalogOverlay_IsVGAConnected(this->m_pINova1) ) { this->BoardCapabilities |= ( MPEG_CAPABILITY_BORDER_ADJUST | MPEG_CAPABILITY_KEYCOLOR_ADJUST | MPEG_CAPABILITY_AUTO_CALIBRATE | MPEG_CAPABILITY_VGA_WINDOW | MPEG_CAPABILITY_ANALOG_CABLE_CONNECTED ); QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("\nAnalog Cable detected") )); this->pRegistry->TvOut = SET_VGA | SET_NTSC | SET_ONETOONE; this->TvOut = SET_VGA; } else { QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("\nAnalog Cable missing") )); // modify the default value for registry to TV this->pRegistry->TvOut = SET_TV | SET_NTSC | SET_ONETOONE; this->TvOut = SET_TV; } this->DeviceId = NETSTREAM2000_DEVICEID; IDecoder_ReadPIO(this->m_pIDecoder, PIO2, &pio2); if ((pio2 == 0) && (this->QuasarVersion >= EM847XA_Q4)) { // new NE4000 boards = no AD7170, external VCXO this->BoardVersion = NE4000_SIGMATV; this->HwVcxo = eHwVcxoPio3; this->BoardCapabilities |= MPEG_CAPABILITY_AUDIO_VCXO; } else this->BoardVersion = (this->QuasarVersion >= EM847XA_Q4)? NE4000: NE2000; this->SubId = (this->BoardVersion>>8); this->DisplayResolution.iScreenWidth = 1024; this->DisplayResolution.iScreenHeight = 768; this->DisplayResolution.iBitsPerPixel = 8; IAnalogOverlay_SetVgaResolution(this->m_pINova1, &this->DisplayResolution); if (this->BoardVersion == NE4000_SIGMATV) { DWORD Value = I2S_SCkinSCIN_ScinIN_DamckIN; IDecoder_SetProperty(this->m_pIDecoder, DECODER_SET, edecAudioInOutConfig, 0, &Value, sizeof(DWORD), NULL); Value = 24; IDecoder_SetProperty(this->m_pIDecoder, DECODER_SET, edecAudioDacBitsPerSample, 0, &Value, sizeof(DWORD), NULL); } else { DWORD Value = I2SInv_SCkinSCIN_Jda1CkinGCK_ScinIN_DamckIN; IDecoder_SetProperty(this->m_pIDecoder, DECODER_SET, edecAudioInOutConfig, 0, &Value, sizeof(DWORD), NULL); Value = 16; IDecoder_SetProperty(this->m_pIDecoder, DECODER_SET, edecAudioDacBitsPerSample, 0, &Value, sizeof(DWORD), NULL); } return Q_OK;}#endif // ANALOG_OVERLAY#if defined NE2000_BRD || defined NE2000TV_BRD#include "cqsrbrd.h"QRESULT CNE2000__VidSetVGA(IDecoderBoard* pIDecoderBoard){ CQuasarBoard *this = (CQuasarBoard*) pIDecoderBoard; DWORD ccir = CCIR_601 | NO_INVERT_FIELD | SYNC_ENABLE_1; // main TV slave with dacs disabled, Nova is master if( this->m_pITvEncoder != this->m_pISigmaTv ) // main TV is extern ITvEncoder_ProgramTV(this->m_pISigmaTv, TVSLAVE, 8, ccir, this->Standard_TvOut, 0); ITvEncoder_ProgramTV(this->m_pITvEncoder, TVSLAVE, 8, ccir, this->Standard_TvOut, 0); IDecoder_QuasarSlave( this->m_pIDecoder, 16, ccir, (this->Standard_TvOut == SET_PAL) ? &this->MasterParamsPal:&this->MasterParamsNtsc, VSHS_ACTIVE_HI, Q3CTRL2_NOINTERLACED | DIGITAL_DATA_ENABLE); // Enable DVCLK from Nova == disable 27 MHz. Disable HDTV. IDecoderBoard_SelectVClk(pIDecoderBoard, VgaVClk, NULL, 0); // Nova DVCLK enable, VRDY selected - show the MPEG IAnalogOverlay_SetVGA(this->m_pINova1); // change resolution if it is any real change and update the overlay CNE2000__VidChangeResolution(pIDecoderBoard, &this->NewDisplayResolution); IDecoder_SetKmin(this->m_pIDecoder, this->SrcWnd.w + 6, this->DefHFrequency * 100); CNE2000__VGAUpdateVideoWindow(pIDecoderBoard); return Q_OK;}QRESULT CNE2000__VidSetHdtvSubd(IDecoderBoard* pIDecoderBoard){ CQuasarBoard *this = (CQuasarBoard*) pIDecoderBoard; DWORD ccir = CCIR_601 | NO_INVERT_FIELD | SYNC_ENABLE_1; // Mpeg FullScreen on VGA monitor, Quasar master, TVs slave and Nova slave if( this->m_pITvEncoder != this->m_pISigmaTv ) // main TV is extern ITvEncoder_ProgramTV(this->m_pISigmaTv, TVSLAVE, 8, ccir, this->Standard_TvOut, 0); ITvEncoder_ProgramTV(this->m_pITvEncoder, TVSLAVE, 8, ccir, this->Standard_TvOut, 0); IAnalogOverlay_SetMode(this->m_pINova1, MpegModeRectangle);// show all IAnalogOverlay_SlaveShowAll(this->m_pINova1); // Disable DVCLK but show Mpeg // all the results are in pixels, updates this->HFrequency CQuasarBoard__HdtvCalc(pIDecoderBoard, 16, &this->HdtvMode, &this->MasterParams, &this->HFrequency); // Disable DVCLK from Nova, Enable HDTV. IDecoderBoard_SelectVClk(pIDecoderBoard, HdtvVClk, &this->HdtvMode.PixelFreq, sizeof(this->HdtvMode.PixelFreq)); this->MasterParams.HSyncTotal = this->HdtvMode.PixelFreq / this->HdtvMode.HFreq; // pixels // Quasar master interlaced or progressive, DVCLK from PLL2, polarity VGA IDecoder_QuasarMaster( this->m_pIDecoder, 16, ccir, &this->MasterParams, this->HdtvMode.Interlaced ? DISPLAY_INTERLACED:DISPLAY_NONINTERLACED, VSHS_ACTIVE_HI, Q3CTRL2_NOINTERLACED | DIGITAL_DATA_ENABLE); CQuasarBoard__HdtvUpdateVideoWindow(pIDecoderBoard); return Q_OK;}QRESULT CNE2000__VidSetTv(IDecoderBoard* pIDecoderBoard, DWORD VideoRunning){ CQuasarBoard *this = (CQuasarBoard*) pIDecoderBoard; DWORD ccir = CCIR_601 | NO_INVERT_FIELD | SYNC_ENABLE_1; // Mpeg FullScreen on TV monitor: Quasar slave, TV master and Nova slave // Nova - DVCLK disable, GND selected - hide the MPEG IAnalogOverlay_SetTv(this->m_pINova1); // use AD717x master ITvEncoder_SetCurrentYcYuvRgb(this->m_pITvEncoder, this->ReqYcYuvRgb); ITvEncoder_ProgramTV(this->m_pITvEncoder, TVMASTER, 8, ccir, this->Standard_TvOut, VideoRunning & ~RST_DC); // main TV if( this->m_pITvEncoder != this->m_pISigmaTv ) // main TV is extern ITvEncoder_ProgramTV(this->m_pISigmaTv, TVSLAVE, 8, ccir, this->Standard_TvOut, VideoRunning & ~RST_DC); // Our Decoder is slave IDecoder_QuasarSlave( this->m_pIDecoder, 8, ccir, (this->Standard_TvOut == SET_PAL) ? &this->MasterParamsPal:&this->MasterParamsNtsc, VSHS_ACTIVE_LOW, Q3CTRL2_NOINTERLACED | DIGITAL_DATA_ENABLE); // Disable DVCLK from Nova == enable 27 MHz. Disable HDTV. IDecoderBoard_SelectVClk(pIDecoderBoard, TvVClk, NULL, 0); CQuasarBoard__TVVMIUpdateVideoWindow(pIDecoderBoard); OSTimeDelay(100000); // wait 100 ms to not see garbage on TV when the switch occur ITvEncoder_DisableTVBlackout(this->m_pITvEncoder); // main TV return Q_OK;}/****f* HwLib/IDecoderBoard_VidSetVGATV * USAGE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -