📄 cnova.c
字号:
else { // Dvclk at maximum value if( (VGACorrection < 300) || (VGACorrection > 3500) ) // if it is an error.. VGACorrection = 1500; } this->m_DefCorrection = VGACorrection; QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT(" Dvclk= %d kHz DefCorr= %d"), Dvclk, this->m_DefCorrection)); CNova__WriteREG12(pIAnalogOverlay, PLL1, (BYTE)(((N>>8) & 0xf) | (K<<4)), (BYTE)N);}/****f* HwLib/CNova__WaitVSync * USAGE * NOT PRESENT in IAnalogInterface * BOOL CNova__WaitVSync(IAnalogOverlay* pIAnalogOverlay) * DESCRIPTION * CNova__WaitVSync is implemented only for Nova(EM9010). It waits for VSync to become low, * then high using HSet bit feature. HSet bit from register 0 is reset when VSync goes low * and it is set againafter VSync low and a preset number(in register 0xB) of HSync-s passed. * CNova__WaitVSync is called by IAnalogOverlay_IsVGAConnected. * PARAMETERS * IN IAnalogOverlay* pIAnalogOverlay - pointer to the overlay object * RETURN VALUE * TRUE if VSync low to high transition was detected, FALSE if timeout more than 50 ms/******************************************************************************/BOOL CNova__WaitVSync(IAnalogOverlay* pIAnalogOverlay){#define VSYNCTIME 50 // ms - timeout waiting VSync DWORD t0, t1; t0 = OSTimeGetTime(); t1 = 1000; // wait HSet to become 0 (VSync goes low) while( CNovaBase__Read( pIAnalogOverlay, 0 ) & 0x20 ) { if (!(--t1)) { if ((OSTimeGetTime()-t0) >= VSYNCTIME) return FALSE; t1 = 1000; } } t0 = OSTimeGetTime(); t1 = 1000; // wait HSet to become 1 (VSync goes high + preset number of HSync-s) while( (!( CNovaBase__Read( pIAnalogOverlay, 0 ) & 0x20) ) ) { if (!(--t1)) { if ((OSTimeGetTime()-t0) >= VSYNCTIME) return FALSE; t1 = 1000; } } return TRUE;}BOOL CNova__IsNOVAPresent(IAnalogOverlay* pIAnalogOverlay){ BYTE byte = 0xaa; CNovaBase__Write( pIAnalogOverlay, 0xb, byte ); if( CNovaBase__Read( pIAnalogOverlay, 0xb ) != byte ) { QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT(" IsNOVAPresent: NOVA not present") )); return FALSE; } return TRUE;}/****f* HwLib/IAnalogOverlay_IsVGAConnected * USAGE * BOOL IAnalogOverlay_IsVGAConnected(IAnalogOverlay* pIAnalogOverlay) * BOOL CNova__IsVGAConnected(IAnalogOverlay* pIAnalogOverlay) * DESCRIPTION * IAnalogOverlay_IsVGAConnected is implemented only for Nova(EM9010). * On an analog design board VSync coming from VGA card is connected to Nova chip through * the external analog cable. If the cable is not connected the board cannot display on * VGA. IAnalogOverlay_IsVGAConnected checks the presence of the cable by detecting if VSync * is connected and in the mean time programming VSync polarity. Nova chip expects only * active high VSync. This function should be called when VGA display mode is changed. * IAnalogOverlay_IsVGAConnected is called by CQuasarBoard__FindDeviceIdSubId, * IDecoderBoard_HwReset and CNE2000__VidChangeResolution. * PARAMETERS * IN IAnalogOverlay* pIAnalogOverlay - pointer to the overlay object * RETURN VALUE * TRUE if VSync is detected, FALSE if timeout more than 50 ms/******************************************************************************/BOOL CNova__IsVGAConnected(IAnalogOverlay* pIAnalogOverlay){ CNovaBase__Write( pIAnalogOverlay, 0xb, 200 ); // HSet will be set after VSync after 200 horizontal lines CNovaBase__Write( pIAnalogOverlay, 9, 0x04 ); // DVCLK enable // bypass VSync polarity detection - bug in NOVA showing up with NVIDIA chipset CNovaBase__Write( pIAnalogOverlay, 0x0D, 0x44 ); // Select HSync input for PLL1, VSync not inverted if( !CNova__WaitVSync( pIAnalogOverlay ) ) { CNovaBase__Write( pIAnalogOverlay, 0x0D, 0x4C );// Select HSync input for PLL1, VSync inverted if( !CNova__WaitVSync( pIAnalogOverlay ) ) { CNovaBase__Write( pIAnalogOverlay, 9, 0x00 );// DVCLK disable return FALSE; } } return TRUE;}void CNova__SetHorizontalFrequency(IAnalogOverlay* pIAnalogOverlay, DWORD dwFreq){ //dwFreq is 10 * KHz QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("CNova__SetHorizontalFrequency NOT IMPLEMENTED"))); }/****f* HwLib/IAnalogOverlay_SetVrdyDelay * USAGE * void IAnalogOverlay_SetVrdyDelay(IAnalogOverlay* pIAnalogOverlay, BYTE delay) * void CNova__SetVrdyDelay(IAnalogOverlay* pIAnalogOverlay, BYTE delay) * DESCRIPTION * IAnalogOverlay_SetVrdyDelay is implemented only for Nova(EM9010). It sets the delay * for VRDY(video ready) signal. "delay" has 7 bits: * - bits 6,5,4 are the coarse delay - the unit of coarse delay is 1 video pixel * - bits 3,2,1,0 are the fine delay - the unit of fine delay is 3ns * When the delay increases video is cropped at left and a black vertical stripe appears at right. * IAnalogOverlay__SetVrdyDelay is called by IDecoderBoard_OverlaySetAttribute + MpegAttrOverlayFineAdjustment./******************************************************************************/void CNova__SetVrdyDelay(IAnalogOverlay* pIAnalogOverlay, BYTE delay){ CNova *this = (CNova*) pIAnalogOverlay; if (delay == this->m_VrdyDelay) return; QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT("VrdyDelay: %ld"), delay)); this->m_VrdyDelay = delay; CNovaBase__Write( pIAnalogOverlay, 0x6, delay );}/****f* HwLib/IAnalogOverlay_GetVrdyDelay * USAGE * DWORD IAnalogOverlay_GetVrdyDelay(IAnalogOverlay* pIAnalogOverlay) * DWORD CNova__GetVrdyDelay(IAnalogOverlay* pIAnalogOverlay) * DESCRIPTION * IAnalogOverlay_GetVrdyDelay is implemented only for Nova(EM9010). * It returns the VRDY delay. * IAnalogOverlay__GetVrdyDelay is called by IDecoderBoard_OverlayGetAttribute + MpegAttrOverlayFineAdjustment./******************************************************************************/DWORD CNova__GetVrdyDelay(IAnalogOverlay* pIAnalogOverlay){ CNova *this = (CNova*) pIAnalogOverlay; return this->m_VrdyDelay;}/****f* HwLib/IAnalogOverlay_SetJitterAdjustment * USAGE * void IAnalogOverlay_SetJitterAdjustment(IAnalogOverlay* pIAnalogOverlay, BYTE val) * void CNova__SetJitterAdjustment(IAnalogOverlay* pIAnalogOverlay, BYTE val) * DESCRIPTION * IAnalogOverlay_SetJitterAdjustment is implemented only for Nova(EM9010). It sets the delay * for pixel clock. "val" has 4 bits, the unit is 3ns. It will affect the horizontal stability. * Unfortunatelly it is different for every VGA mode and it has to be adjusted manually. * IAnalogOverlay__SetVrdyDelay is called by IDecoderBoard_OverlaySetAttribute + MpegAttrOverlayJitterAdjustment./******************************************************************************/void CNova__SetJitterAdjustment(IAnalogOverlay* pIAnalogOverlay, BYTE val){ CNova *this = (CNova*) pIAnalogOverlay; if (val == this->m_JitterAdj) return; QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT("Jitter: %ld"), val)); this->m_JitterAdj = val; CNovaBase__Write (pIAnalogOverlay, 0x7, (BYTE)(val | ( CNovaBase__Read(pIAnalogOverlay, 0x7) & 0xF0)) );}/****f* HwLib/IAnalogOverlay_GetJitterAdjustment * USAGE * DWORD IAnalogOverlay_GetJitterAdjustment(IAnalogOverlay* pIAnalogOverlay) * DWORD CNova__GetJitterAdjustment(IAnalogOverlay* pIAnalogOverlay) * DESCRIPTION * IAnalogOverlay_GetJitterAdjustment is implemented only for Nova(EM9010). * It returns the pixel clock delay. * IAnalogOverlay__GetJitterAdjustment is called by IDecoderBoard_OverlayGetAttribute + MpegAttrOverlayJitterAdjustment./******************************************************************************/DWORD CNova__GetJitterAdjustment(IAnalogOverlay* pIAnalogOverlay){ CNova *this = (CNova*) pIAnalogOverlay; return this->m_JitterAdj;}/****f* HwLib/IAnalogOverlay_MakeMask * USAGE * DWORD IAnalogOverlay_MakeMask(IAnalogOverlay* pIAnalogOverlay, IN DWORD Upper, IN DWORD Lower) * DWORD CNova__MakeMask(IAnalogOverlay* pIAnalogOverlay, IN DWORD Upper, IN DWORD Lower) * DESCRIPTION * IAnalogOverlay_MakeMask is implemented only for Nova(EM9010). * Nova chip has VGA signals coming from the video card(RGB,VSync,HSync) like inputs and it * outputs the same signals(RGB,VSync,HSync) to the VGA monitor , eventually mixed with * the Mpeg video. * The Nova analog overlay multiplexor has RGB VGA signals and RGB Mpeg signals like inputs. * When the VRDY(video ready) signal is valid the output of the mux is selected by the chroma * key mask and chroma key limits, programmed by user in Nova registers. * There are six analog comparators (upper and lower for every red, green and blue). * Each RGB VGA signal is compared to a upper and lower limit. If the RGB signal is within * these limits and the RGB mask bits are reset -> the RGB Mpeg signal is selected for output, * otherwise the RGB VGA signal is selected for output. * In other words Nova will show the Mpeg instead of VGA on the VGA monitor, in a window * validated by VRDY signal and by the VGA color choosed by user. * Register 0xA of Nova is used to mask or unmask any of the six analog comparators. * Bits 6,5,4 are upper mask for RGB, Bits 2,1,0 are lower mask for RGB. * Writing a "1" on any of mask bits disables the corresponding analog comparator and the * Mpeg signal will be forcedly selected. * IAnalogOverlay_MakeMask builds the mask value to write in register 0xA based on the * chroma key selected "Upper" and "Lower". "Upper" and "Lower" are the limits required for * chroma key( byte2 is Blue, byte 1 is Green, byte 0 is Red). * If any of R,G,B are 0 on "Lower" the lower mask is set(to avoid hardware limitation). * If any of R,G,B are 0xFF on "Upper" the upper mask is set(to avoid hardware limitation). * IAnalogOverlay_MakeMask is called by IAnalogOverlay_UpdateColorKey. * PARAMETERS * IN IAnalogOverlay* pIAnalogOverlay - pointer to the overlay object * IN DWORD Upper - chroma key upper limit * IN DWORD Lower - chroma key lower limit * RETURN VALUE * It returns the mask that should be programmed in mask register. * SEE ALSO * IAnalogOverlay_Hide, IAnalogOverlay_ShowAll, IAnalogOverlay_SetChromaKey/******************************************************************************/DWORD CNova__MakeMask(IAnalogOverlay* pIAnalogOverlay, IN DWORD Upper, IN DWORD Lower){ DWORD Mask = 0; if ((Lower & 0xFF) == 0x00) Mask |= 4; if ((Lower & 0xFF00) == 0x0000) Mask |= 2; if ((Lower & 0xFF0000) == 0x000000) Mask |= 1; if ((Upper & 0xFF) == 0xFF) Mask |= 0x40; if ((Upper & 0xFF00) == 0xFF00) Mask |= 0x20; if ((Upper & 0xFF0000) == 0xFF0000) Mask |= 0x10; QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT("MakeMask %x Upper=%xLower=%x"), Mask, Upper, Lower)); return Mask;}/****f* HwLib/IAnalogOverlay_Hide * USAGE * void IAnalogOverlay_Hide(IAnalogOverlay* pIAnalogOverlay) * void CNova__Hide(IAnalogOverlay* pIAnalogOverlay) * DESCRIPTION * IAnalogOverlay_Hide is implemented only for Nova(EM9010). * Register 0xA of Nova is used to mask or unmask any of the six analog comparators. * Bits 6,5,4 are upper mask for RGB, Bits 2,1,0 are lower mask for RGB. * Writing a "1" on any of mask bits disables the corresponding analog comparator and the * Mpeg signal will be forcedly selected. * IAnalogOverlay_Hide writes all the mask bits to 0 to select the analog comparators and * it writes the chroma key limits reversed in order that the Mpeg signal to not show up. * IAnalogOverlay_Hide is called by IAnalogOverlay_InitAnalogMux and * IAnalogOverlay_UpdateColorKey when MPEG_OVERLAY_MODE is MpegModeRectangle. * PARAMETERS * IN IAnalogOverlay* pIAnalogOverlay - pointer to the overlay object * SEE ALSO * IAnalogOverlay_MakeMask, IAnalogOverlay_ShowAll, IAnalogOverlay_SetChromaKey/******************************************************************************/void CNova__Hide(IAnalogOverlay* pIAnalogOverlay){ CNova *this = (CNova*) pIAnalogOverlay; if(this->VGAKeyMask == OVERLAY_HIDDEN) // already hidden return; this->VGAKeyMask = OVERLAY_HIDDEN; CNova__WriteREG12( pIAnalogOverlay, RLIMIT, 0x00, 0xff); CNova__WriteREG12( pIAnalogOverlay, GLIMIT, 0x00, 0xff); CNova__WriteREG12( pIAnalogOverlay, BLIMIT, 0x00, 0xff); CNovaBase__Write( pIAnalogOverlay, 0xa, 00 ); }/****f* HwLib/IAnalogOverlay_SetChromaKey * USAGE * DWORD IAnalogOverlay_SetChromaKey(IAnalogOverlay* pIAnalogOverlay, DWORD VGAKeyUpper, DWORD VGAKeyLower, DWORD VGAKeyMask) * DWORD CNova__SetChromaKey(IAnalogOverlay* pIAnalogOverlay, DWORD VGAKeyUpper, DWORD VGAKeyLower, DWORD VGAKeyMask) * DESCRIPTION * IAnalogOverlay_SetChromaKey is implemented only for Nova(EM9010). * Nova chip has VGA signals coming from the video card(RGB,VSync,HSync) like inputs and it * outputs the same signals(RGB,VSync,HSync) to the VGA monitor , eventually mixed with * the Mpeg video. * The Nova analog overlay multiplexor has RGB VGA signals and RGB Mpeg signals like inputs. * When the VRDY(video ready) signal is valid the output of the mux is selected by the chroma * key mask and chroma key limits, programmed by used in Nova registers. * There are six analog comparators (upper and lower for every red, green and blue).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -