📄 cne2ktv.c
字号:
switch (EepromByte & 0xC0) // TV standard mask { case 0x40: // Pal IScanConverter_SetTVStandard(this->m_pIScanConverter, SET_PAL); break; case 0x80: // 480P IScanConverter_SetTVStandard(this->m_pIScanConverter, SET_480P); break; default: case 0x00: // Ntsc IScanConverter_SetTVStandard(this->m_pIScanConverter, SET_NTSC); break; } switch (EepromByte & 0x30) // scart mask { case 0x00: // scart off Value = SCART_DISABLE; break; case 0x10: // scart 4x3 !!! case 0x20: // scart 16x9 !!! default: Value = SCART_COMPOSITE; break; } CNE2000TV__SetVideoProperty(pIDecoderBoard, VIDEO_SET, evScartOutput, 0, &Value, sizeof(DWORD), NULL); switch (EepromByte & 0x07) // format mask { case 0x00: Value = COMPOSITE; break; case 0x01: Value = COMPONENT_YUV; break; case 0x02: Value = COMPONENT_RGB; break; case 0x03: Value = OUTPUT_OFF; break; } IScanConverter_SetProperty(this->m_pIScanConverter, SCANCONVERTER_SET, escOutputFormat, 0, &Value, sizeof(DWORD), NULL); IDecoderBoard_SetProperty(pIDecoderBoard, VIDEO_SET, evTvOutputFormat, 0, &Value, sizeof(DWORD), NULL); // program the default focus position and size - from eeprom IEeprom_Read(this->m_pIEeprom, 23, &EepromByte); Value = EepromByte; IEeprom_Read(this->m_pIEeprom, 24, &EepromByte); Value |= (EepromByte<<8); if (Value != 0) // 0 is default value, don't overwrite focus register! IScanConverter_SetProperty(this->m_pIScanConverter, SCANCONVERTER_SET, escHwOutputHorzOffsShadow, 0, &Value, sizeof(DWORD), NULL); IEeprom_Read(this->m_pIEeprom, 25, &EepromByte); Value = EepromByte; IEeprom_Read(this->m_pIEeprom, 26, &EepromByte); Value |= (EepromByte<<8); if (Value != 0) // 0 is default value, don't overwrite focus register! IScanConverter_SetProperty(this->m_pIScanConverter, SCANCONVERTER_SET, escHwOutputVertOffsShadow, 0, &Value, sizeof(DWORD), NULL); IEeprom_Read(this->m_pIEeprom, 29, &EepromByte); Value = EepromByte; IEeprom_Read(this->m_pIEeprom, 30, &EepromByte); Value |= (EepromByte<<8); if (Value != 0) // 0 is default value, don't overwrite focus register! IScanConverter_SetProperty(this->m_pIScanConverter, SCANCONVERTER_SET, escTVPixels, 0, &Value, sizeof(DWORD), NULL); IEeprom_Read(this->m_pIEeprom, 27, &EepromByte); Value = EepromByte; IEeprom_Read(this->m_pIEeprom, 28, &EepromByte); Value |= (EepromByte<<8); if (Value != 0) // 0 is default value, don't overwrite focus register! IScanConverter_SetProperty(this->m_pIScanConverter, SCANCONVERTER_SET, escTVLines, 0, &Value, sizeof(DWORD), NULL); }}QRESULT CNE2000TV__HwReset(IDecoderBoard* pIDecoderBoard){ CQuasarBoard *this = (CQuasarBoard*) pIDecoderBoard; QRESULT qr = Q_OK; CommonSymbolTable* pQ = (CommonSymbolTable*)this->pQ; int i = 0; DWORD temp; this->m_bEnableSync = TRUE; this->FirstSystemSCR = TRUE; this->VideoState = VideoStoppedAfterReset; if( !this->pRegistry->DoHwReset ) return CQuasarBoard__DontDoHwReset(pIDecoderBoard); IDecoder_WritePIO(this->m_pIDecoder, PIO7, 1); // disable Focus I2C // sometimes reset is failing on rev A1 of the board and I believe it is // because of Nova1 - cannot be accessed anymore ?? IAnalogOverlay_Write(this->m_pINova1, 0xe, 0); // ?? // program TV with Dacs disable before HwReset to minimize flashing on TV if(this->m_pIExtTv) ITvEncoder_InitTvEncoder(this->m_pIExtTv); //Risc and DRAM Init, set channels priorities, download microcode if( QFAILED(qr = IDecoder_HwReset(this->m_pIDecoder)) ) return qr; // Restore the PIO state for (i = 0;i< 16;i++) { if( (this->PioAccessedByUser>>i) && 1 ) // PIO accessed by user { if( (this->PioDirState>>i) && 1) // PIO is Output IDecoder_WritePIO(this->m_pIDecoder, i, (this->PioDataState>>i) & 1 ); else // PIO is input IDecoder_ReadPIO(this->m_pIDecoder, i, &temp ); } } IDecoder_WritePIO(this->m_pIDecoder, PIO7, 1); // disable Focus I2C ITvEncoder_InitTvEncoder(this->m_pISigmaTv); IDecoder_InitCloseCaption(this->m_pIDecoder); IAnalogOverlay_SetVgaResolution(this->m_pINova1, &this->DisplayResolution); IAnalogOverlay_InitAnalogMux(this->m_pINova1, this->pRegistry->MaximumDvclk); if( OSmemcmp (&this->NewDisplayResolution, &this->DisplayResolution, sizeof (MPEG_DISPLAY_RESOLUTION)) ) { OSmemcpy (&this->NewDisplayResolution, &this->DisplayResolution, sizeof (MPEG_DISPLAY_RESOLUTION)); this->DisplayResolutionChanged = 1; } IAnalogOverlay_InitAnalogMux(this->m_pINovaLite, 0); // force the hardware to init shift register and center vcxo this->RegControl = 0x3000; CNE2000TV__InitShiftRegister(pIDecoderBoard); this->ReqYcYuvRgb = OUTPUT_OFF;// analog Tv dacs are off IDecoderBoard_VidSetVGATV(pIDecoderBoard, 0, this->TvOut); // force the hardware to set the sample rate IDecoderBoard_AudioSetSampleRate(pIDecoderBoard, this->BoardAudioRate | FORCED_HW_UPDATE); if(this->PixelClockPolarity == 1) { IDecoder_WriteDM(this->m_pIDecoder, pQ->DICOM_Control2.addr, IDecoder_ReadDM(this->m_pIDecoder, pQ->DICOM_Control2.addr) | Q3CTRL2_PIXCLK_POLARITY); } if(this->VideoClipEnable == 1) { IDecoder_WriteDM(this->m_pIDecoder, pQ->DICOM_Control2.addr, IDecoder_ReadDM(this->m_pIDecoder, pQ->DICOM_Control2.addr) | Q3CTRL2_VIDEO_CLIP_ENABLE); } IDecoder_WriteDM(this->m_pIDecoder, pQ->Force_PanScanDefHorSize.addr, this->Force_PanScanDefHorSize); if( QFAILED(qr = IDecoder_HwStart(this->m_pIDecoder)) ) return qr; // Risc Start and BlackFrame if(this->TvOut == SET_VGA) this->IsInterlaced = IDecoder_IsInterlaced (this->m_pIDecoder, this->DisplayResolution.iScreenHeight); IDecoderBoard_UpdateOverlay(pIDecoderBoard); IDecoder_SetCurrentIrqMask( this->m_pIDecoder, 0 ); return Q_OK;}QRESULT CNE2000TV__SelectVClk(IDecoderBoard* pIDecoderBoard, VCLK_TYPE Type, void* pContext, DWORD ContextSize){ CQuasarBoard *this = (CQuasarBoard*) pIDecoderBoard; switch(Type) { case HdtvVClk: CNE2000TV__SetOutputFormat(pIDecoderBoard, this->ReqOutputFormat); CNE2000__ProgramVclkForHdtv(pIDecoderBoard); CNE2000TV__ShiftRegister(pIDecoderBoard, ~NE2000TV_OUTPUT_MASK, NE2000TV_HDTV); break; case TvVClk: CNE2000TV__SetOutputFormat(pIDecoderBoard, this->ReqYcYuvRgb); CNE2000TV__ShiftRegister(pIDecoderBoard, ~NE2000TV_OUTPUT_MASK, NE2000TV_TV); break; case VgaVClk: CNE2000TV__SetOutputFormat(pIDecoderBoard, this->ReqOutputFormat); CNE2000TV__ShiftRegister(pIDecoderBoard, ~NE2000TV_OUTPUT_MASK, NE2000TV_VGA); break; case VideoInClk: // impossible case break; } return Q_OK;}QRESULT CNE2000TV__SetAudioFineVcxo(IDecoderBoard* pIDecoderBoard, DWORD PropSet, DWORD PropId, DWORD Flags, void* pData, DWORD dwSizeIn, DWORD* pdwSizeOut){ // CQuasarBoard *this = (CQuasarBoard*) pIDecoderBoard; // this vcxo affects the 27MHz input for audio clock // hardware supports -150ppm, -75ppm, 0ppm, +75ppm, +150ppm DWORD VcxoTable[5] = {0xF000, 0x7000, 0x3000, 0x1000, 0x0000}; // pData contains number of ppm, positive or negative int index = *(int*)(pData) / 75; if( (index < -2) || (index > 2) ) { QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT(" SetAP: eAudioFineVcxo unsupported setting=%d!!!"), index )); return E_NOT_SUPPORTED; } CNE2000TV__ShiftRegister(pIDecoderBoard, ~0xF000, VcxoTable[index + 2]); return Q_OK;}QRESULT CNE2000TV__SelectOutputForVideo(IDecoderBoard* pIDecoderBoard, DWORD General_TvOut){ CQuasarBoard *this = (CQuasarBoard*) pIDecoderBoard; DWORD NewTvOut; DWORD OldTvStandard = this->Standard_TvOut; DWORD OldTvNoScaling = this->TvNoScaling; DWORD OldYcYuvRgb = this->ReqYcYuvRgb; DWORD OldTvDacsState = this->TvDacsState ? TV_DACS_ENABLE : TV_DACS_DISABLE; QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("***CNE2000TV__SelectOutputForVideo = %x"), General_TvOut)); if ( !(General_TvOut & FORCED_HW_UPDATE) && ( General_TvOut == (this->TvOut | this->Standard_TvOut | this->TvNoScaling | this->TvAsSource | OldTvDacsState | OldYcYuvRgb) ) && (!this->m_bUpdateVideoPort) ) return Q_OK; NewTvOut = General_TvOut & VIDEOOUT_MASK; this->TvNoScaling = General_TvOut & SET_SCALE; this->TvDacsState = (General_TvOut & TV_DACS_DISABLE) ? 0:HW_TV_DACS_ENABLE; this->ReqYcYuvRgb = General_TvOut & COMPONENT_MASK; if(this->ReqYcYuvRgb == OUTPUT_OFF) this->TvDacsState = 0; else this->TvDacsState = HW_TV_DACS_ENABLE; this->TvAsSource = General_TvOut & SET_TV_AS_SOURCE; if(this->TvAsSource == SET_TV_AS_SOURCE) { if(this->VideoMode == MPEG_ATTRIBUTE_VIDEO_PAL) // PAL input this->Standard_TvOut = SET_PAL; else this->Standard_TvOut = SET_NTSC; } else this->Standard_TvOut = General_TvOut & STANDARDTV_MASK; if( this->BoardCapabilities & MPEG_CAPABILITY_VGA_WINDOW )// analog cable connected { if( (this->TvOut == SET_VGA) && (NewTvOut == SET_VGA) ) { this->m_bUpdateVideoPort = FALSE; return Q_OK; // no need to update TV - it will be done when we choose TV } } else // no analog cable connected { DWORD Value; if( OldYcYuvRgb != this->ReqYcYuvRgb ) { Value = this->ReqYcYuvRgb; IScanConverter_SetProperty(this->m_pIScanConverter, SCANCONVERTER_SET, escOutputFormat, 0, &Value, sizeof(DWORD), NULL); } if( OldTvStandard != this->Standard_TvOut ) { Value = this->Standard_TvOut; IScanConverter_SetProperty(this->m_pIScanConverter, SCANCONVERTER_SET, escTvStandard, 0, &Value, sizeof(DWORD), NULL); } } if ( (General_TvOut & FORCED_HW_UPDATE) || (NewTvOut != this->TvOut) || (OldTvStandard != this->Standard_TvOut ) || ((DWORD)(OldTvDacsState ? 0:HW_TV_DACS_ENABLE) != this->TvDacsState) || (OldYcYuvRgb != this->ReqYcYuvRgb) || (OldTvNoScaling != this->TvNoScaling) || this->m_bUpdateVideoPort ) { this->m_bUpdateVideoPort = FALSE; return IDecoderBoard_VidSetVGATV(pIDecoderBoard, RST_DC | this->TvDacsState, NewTvOut); } else return Q_OK; // same settings no need to update hardware}void CNE2000TV__InitVtable(IDecoderBoard* pIDecoderBoard){ CQuasarBoard* this = (CQuasarBoard*) pIDecoderBoard; CNE2000Common__InitVtable(pIDecoderBoard); this->lpVtbl->VidSetVGATV = CNE2000__VidSetVGATV; this->lpVtbl->AudioSetSampleRate = CNE2000__AudioSetSampleRate; this->lpVtbl->HwReset = CNE2000TV__HwReset; this->lpVtbl->SelectOutputForVideo = CNE2000TV__SelectOutputForVideo; this->lpVtbl->SelectVClk = CNE2000TV__SelectVClk; this->VideoPropertyList[evTvOutputFormat].fnSet = (PFUNCT)CNE2000TV__SetVideoProperty; this->VideoPropertyList[evTvOutputFormat].fnGet = (PFUNCT)CNE2000TV__GetVideoProperty; this->VideoPropertyList[evTvStandard].fnSet = (PFUNCT)CNE2000TV__SetVideoProperty; this->VideoPropertyList[evScartOutput].fnSet = (PFUNCT)CNE2000TV__SetVideoProperty; this->VideoPropertyList[evScartOutput].fnGet = (PFUNCT)CNE2000TV__GetVideoProperty; this->AudioPropertyList[eAudioFineVcxo].fnSet = (PFUNCT)CNE2000TV__SetAudioFineVcxo;}QRESULT CNE2000TV__SpecificCreateInstance(IDecoderBoard* pIDecoderBoard, DWORD dwInstance){ CQuasarBoard* this = (CQuasarBoard*) pIDecoderBoard; QRESULT qr; DWORD TvEncoderId = 1; if( QFAILED(qr = CNE2000Common__SpecificCreateInstance(pIDecoderBoard, dwInstance)) ) return qr; // Create CTvEncoder instance if( ModCreateInstance (dwInstance, &CLSID_CTVENCODER, &IID_ITVENCODER, (void**)&this->m_pIExtTv) != NOERROR) { return Q_FAIL; } ISetI2CpIO_SetI2C_params( this->m_pISetI2CpIO, I2C_PIO_DATA, I2C_PIO_CLOCK); ITvEncoder_Init(this->m_pIExtTv, &TvEncoderId); ITvEncoder_SetRegistry(this->m_pIExtTv, this->pRegistry); this->m_pITvEncoder = this->m_pIExtTv; // Create also CNovaLite instance if( ModCreateInstance (dwInstance, &CLSID_CNOVALITE, &IID_IANALOGOVERLAY, (void**)&this->m_pINovaLite) != NOERROR ) { return Q_FAIL; } ISetI2CpIO_SetI2C_params( this->m_pISetI2CpIO, SECOND_I2C_DATA_PIO, SECOND_I2C_PIO_CLOCK); IAnalogOverlay_Init(this->m_pINovaLite, NULL); IAnalogOverlay_SetRegistry(this->m_pINovaLite, this->pRegistry); ISetI2CpIO_SetI2C_params( this->m_pISetI2CpIO, I2C_PIO_DATA, I2C_PIO_CLOCK); // Create Cfs400 instance if( ModCreateInstance (dwInstance, &CLSID_CFS400, &IID_ISCANCONVERTER, (void**)&this->m_pIScanConverter) != NOERROR ) { return Q_FAIL; } IScanConverter_Init(this->m_pIScanConverter); IScanConverter_InitPropertySet(this->m_pIScanConverter, this->pPropSetList, sizeof(PROPERTY_SET_ITEM)); // overwrite necessary values CNE2000TV__InitVtable(pIDecoderBoard); this->BoardVersion = NE2000TV; this->SubId = (this->BoardVersion>>8); if( (IDecoder_ReadReg(this->m_pIDecoder, DRAM_startup) & 0x3C) != MDCFG_NE2000TV ) QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("\n\nERROR: Create NE2000TV is FORCED !") )); return Q_OK;}#endif // NE2000TV_BRD#if defined NE2000TV_BRD && !defined ANY_BRDQRESULT CreateInstance(DWORD* pInstance, void* pHwLibConf){ QRESULT qr = CommonCreateInstance(pInstance, pHwLibConf); if( QSUCCEEDED(qr) ) qr = CNE2000TV__SpecificCreateInstance(g_pIDecoderBoard[*pInstance], *pInstance); if( QFAILED(qr) ) { CQuasarBoard__DeleteObjects(g_pIDecoderBoard[*pInstance]); g_pIDecoderBoard[*pInstance] = 0; return E_CREATE_INSTANCE_FAILED; } return Q_OK;}#endif // NE2000TV_BRD && !ANY_BRD
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -