cfs400.c
来自「这是一个SIGMA方案的PMP播放器的UCLINUX程序,可播放DVD,VCD,」· C语言 代码 · 共 602 行 · 第 1/2 页
C
602 行
/*------------------------------------------------------------------------------------------*//* cfs400.c : Implementation of video scan converter interface* REALmagic Quasar Hardware Library* Created by Aurelia Popa-Radu* Copyright Sigma Designs Inc* Sigma Designs Proprietary and confidential* Created on 12/5/00* Description:/*------------------------------------------------------------------------------------------*//****h* HwLib/IScanConverter_implementation * NAME * IScanConverter_implementation * DESCRIPTION * Cfs400 implementation of the IScanConverter interface. * COPYRIGHT * Copyright Sigma Designs Inc * Sigma Designs Proprietary and confidential/********************************************************************************************/#include "pch.h"#if defined FS400_OBJECT#include "ci2c.h"#include "cfs400.h"// For now I let the Focus object mixed with the board - not too nice#define I2C_PIO_CLOCK PIO0#define CURRENT_MACROVISION 0xFFIScanConverterVtbl g_Cfs400Vtbl ={ Cfs400__Delete, Cfs400__Init, Cfs400__Write, Cfs400__Read, Cfs400__InitPropertySet, Cfs400__SetProperty, Cfs400__GetProperty, Cfs400__EnableMacrovision, Cfs400__SetTVStandard, Cfs400__SetOutputFormat, Cfs400__GetOutputFormat, Cfs400__Test};////////////////////////////////////////////////////////////////////////////****f* HwLib/Cfs400__CreateInstance * USAGE * NOT PRESENT in IScanConverter interface * void Cfs400__CreateInstance(void **pv, DWORD dwInstance) * DESCRIPTION * Cfs400__CreateInstance - allocates memory for a new ScanConverter object * PARAMETERS * IN DWORD dwInstance - instance passed down by CreateInstance. * OUT void** pv - Points to a 32-bit variable that receives the pointer to object * SEE ALSO * Cfs400__CreateInstance/********************************************************************************************/void Cfs400__CreateInstance(void **pv, DWORD dwInstance){ Cfs400__New((Cfs400**)pv, TEXT("Focus"), TRUE, dwInstance);}/****f* HwLib/Cfs400__New * USAGE * NOT PRESENT in IScanConverter interface * void Cfs400__New(Cfs400** ppCfs400, TCHAR *pName, BOOL bAllocate, DWORD dwInstance) * DESCRIPTION * Cfs400__New - allocates memory for a new ScanConverter object and plays the role of * the constructor in C++. * PARAMETERS * OUT Cfs400** ppCfs400 - Points to a 32-bit variable that receives the pointer to object * IN TCHAR *pName - pointer to string containing the name of the object - debug purposes. * BOOL bAllocate - usually called with TRUE to allocate memory for object. * - if FALSE ppCfs400 should point to an object already created. * IN DWORD dwInstance - instance passed down by CreateInstance. * SEE ALSO * IScanConverter_Delete/********************************************************************************************/void Cfs400__New ( Cfs400** ppCfs400, TCHAR *pName, BOOL bAllocate, DWORD dwInstance){ Cfs400* this = *ppCfs400; if (bAllocate) { // Allocate Cfs400 *ppCfs400 = OSmalloc(sizeof(Cfs400)); this = (Cfs400*) *ppCfs400; if(this == NULL) return; OSmemset(this, 0, sizeof(Cfs400)); } // Call CObject constructor with bAllocate = FALSE CObject__New ((CObject**)ppCfs400, pName, FALSE, dwInstance); // Call CI2C constructor CI2C__New ( (CI2C**)(&this->m_pII2C), pName, TRUE, dwInstance ); if(this->m_pII2C == NULL) { if (bAllocate) OSfree(*ppCfs400); *ppCfs400 = NULL; return; } // Initialize members this->lpVtbl = &g_Cfs400Vtbl ; // initialize in some unknown state to force hardware to be updated this->CurrentOutputFormat = 0xFFFFFFFF; this->CurrentTvStandard = 0xFFFFFFFF;}/****f* HwLib/IScanConverter_Delete * USAGE * IScanConverter_Delete(IScanConverter* pIScanConverter, BOOL bDeleteObject) * Cfs400__Delete(IScanConverter* pIScanConverter, BOOL bDeleteObject) * DESCRIPTION * IScanConverter_Delete - frees memory for the specified ScanConverter object. * IScanConverter_Delete plays the role of the destructor in C++. * PARAMETERS * IN IScanConverter* pIScanConverter - pointer to the object created by a previous * call to Cfs400__CreateInstance or Cfs400__New. * BOOL bDeleteObject - usually called with TRUE to free memory for object. * - if FALSE doesn't free any memory. * SEE ALSO * Cfs400__CreateInstance, Cfs400__New/********************************************************************************************/void Cfs400__Delete ( IScanConverter* pIScanConverter, BOOL bDeleteObject ){ Cfs400* this = (Cfs400*) pIScanConverter ; if (this == NULL) return; // Release what we were using // Call CI2C Destructor II2C_Delete ( this->m_pII2C, bDeleteObject ); // Call CObject Destructor CObject__Delete ((IObject*)this, FALSE); if (bDeleteObject) { // Delete Cfs400 OSfree(pIScanConverter); }}/****f* HwLib/IScanConverter_Init * USAGE * void IScanConverter_Init(IScanConverter* pIScanConverter) * void Cfs400__Init(IScanConverter* pIScanConverter) * DESCRIPTION * IScanConverter_Init - initialize the ScanConverter object * It is called by CreateInstance. * PARAMETERS * IN IScanConverter* pIScanConverter - pointer to the ScanConverter object/********************************************************************************************/void Cfs400__Init ( IScanConverter* pIScanConverter ){ Cfs400* this = (Cfs400*) pIScanConverter; int i; WORD Zero=0; QueryInterface(this->m_dwInstance, IID_IDECODER, (void**)&(this->m_pIDecoder)); QueryInterface(this->m_dwInstance, IID_IDECODERBOARD, (void**)&(this->m_pIDecoderBoard)); // delay for 1 I2C clock time. For normal speed I2C, this is 4.7ms. II2C_SetI2CAddress( this->m_pII2C, FOCUS450_WRITE_ADDR, FOCUS450_READ_ADDR, 5); // WriteAddr=0x94, ReadAddr=0x95, it needs delay II2C_Init( this->m_pII2C ); for(i=0; i<10; i++) Cfs400__Write(pIScanConverter, 2*(32 + i),&Zero);}////////////////////////////////////////////////////////////////////////////////////////////// Focus functions/****f* HwLib/IScanConverter_Write * USAGE * BOOL IScanConverter_Write(IScanConverter* pIScanConverter, DWORD Address, WORD* pData) * BOOL Cfs400__Write(IScanConverter* pIScanConverter, DWORD Address, WORD* pData) * PARAMETERS * IN IScanConverter* pIScanConverter - pointer to the ScanConverter object * IN DWORD Address - address of the I2C register to write * IN DWORD* pData - pointer to the WORD data to write/********************************************************************************************/BOOL Cfs400__Write( IScanConverter* pIScanConverter, DWORD Address, WORD* pData ){ Cfs400* this = (Cfs400*) pIScanConverter; DWORD IrqMask, temp; BOOL bRet; IrqMask = IDecoder_GetCurrentIrqMask(this->m_pIDecoder); IDecoder_SetCurrentIrqMask(this->m_pIDecoder, 0); // minimize the noise on Clock line when we switch to Focus I2C IDecoder_WritePIO(this->m_pIDecoder, I2C_PIO_CLOCK, 1); IDecoder_WritePIO(this->m_pIDecoder, PIO7, 0); // enable Focus I2C bRet = II2C_Write(this->m_pII2C, (BYTE)Address, (BYTE*)pData, 2); QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT(" WriteFocus at %x = %x"), Address, *pData)); IDecoder_WritePIO(this->m_pIDecoder, I2C_PIO_CLOCK, 1); IDecoder_WritePIO(this->m_pIDecoder, PIO7, 1); // disable Focus I2C IDecoder_ReadPIO(this->m_pIDecoder, I2C_PIO_CLOCK, &temp); IDecoder_SetCurrentIrqMask(this->m_pIDecoder, IrqMask); return bRet;}/****f* HwLib/IScanConverter_Read * USAGE * BOOL IScanConverter_Read(IScanConverter* pIScanConverter, DWORD Address, WORD* pData) * BOOL Cfs400__Read(IScanConverter* pIScanConverter, DWORD Address, WORD* pData) * PARAMETERS * IN IScanConverter* pIScanConverter - pointer to the ScanConverter object * IN DWORD Address - address of the I2C register to read * IN DWORD* pData - pointer where the WORD data is read/********************************************************************************************/BOOL Cfs400__Read( IScanConverter* pIScanConverter, DWORD Address, WORD* pData ){ Cfs400* this = (Cfs400*) pIScanConverter; DWORD IrqMask, temp; BOOL bRet; IrqMask = IDecoder_GetCurrentIrqMask(this->m_pIDecoder); IDecoder_SetCurrentIrqMask(this->m_pIDecoder, 0); // minimize the noise on Clock line when we switch to Focus I2C IDecoder_WritePIO(this->m_pIDecoder, I2C_PIO_CLOCK, 1); IDecoder_WritePIO(this->m_pIDecoder, PIO7, 0); // enable Focus I2C bRet = II2C_Read(this->m_pII2C, (BYTE)Address, (BYTE*)pData, 2); QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT(" ReadFocus at %x = %x"), Address, *pData)); IDecoder_WritePIO(this->m_pIDecoder, I2C_PIO_CLOCK, 1); IDecoder_WritePIO(this->m_pIDecoder, PIO7, 1); // disable Focus I2C IDecoder_ReadPIO(this->m_pIDecoder, I2C_PIO_CLOCK, &temp); IDecoder_SetCurrentIrqMask(this->m_pIDecoder, IrqMask); return bRet;}void Cfs400__InitPropertySet(IScanConverter* pIScanConverter, void* pPropSet, DWORD dwSize){ Cfs400* this = (Cfs400*) pIScanConverter; if(dwSize != sizeof(PROPERTY_SET_ITEM)) return; InitPropSet(pIScanConverter, pPropSet, SCANCONVERTER_SET, escScanConverterMax,\ this->ScanConverterPropertyList, Cfs400__SetProperty, Cfs400__GetProperty)}/****f* HwLib/IScanConverter_SetProperty * USAGE * QRESULT IScanConverter_SetProperty(IScanConverter* pIScanConverter, * DWORD PropSet, DWORD PropId, DWORD* pdwSize, void* pData) * QRESULT Cfs400__SetProperty(IScanConverter* pIScanConverter, * DWORD PropSet, DWORD PropId, DWORD* pdwSize, void* pData) * PARAMETERS * IN IScanConverter* pIScanConverter - pointer to the ScanConverter object * IN DWORD Address - address of the I2C register to read/********************************************************************************************/#define CASE_SET_SCANCONVERTER_PROPERTY(x, y)\case x:\ IScanConverter_Write(pIScanConverter, FS400_##y, (WORD*)&Value);\ break;#define CASE_SET_SCANCONVERTER_PROPERTY_DELAY(x, y)\case x:\ IScanConverter_Write(pIScanConverter, FS400_##y, (WORD*)&Value);\ OSTimeDelay(10 * 1000); /* 10...25 ms delay after write ! */\ break;QRESULT Cfs400__SetProperty( IScanConverter* pIScanConverter, DWORD PropSet, DWORD PropId, DWORD Flags, void* pData, DWORD dwSizeIn, DWORD* pdwSizeOut){ // SCANCONVERTER_SET use DWORD for changing information and size condition is already checked Cfs400* this = (Cfs400*) pIScanConverter; WORD wData; DWORD Value = *(DWORD*)pData; // QRESULT qr = Q_OK; QDbgLog((QLOG_TRACE, QDebugLevelTrace, TEXT(" --> Cfs400__SetProperty: set=%x id=%x flags=%x sz=%x value=%x"), PropSet, PropId, Flags, dwSizeIn, Value)); switch(PropId) { CASE_SET_SCANCONVERTER_PROPERTY(escBrightness, BRT) CASE_SET_SCANCONVERTER_PROPERTY(escContrast, CON) CASE_SET_SCANCONVERTER_PROPERTY(escSaturation,CSC) CASE_SET_SCANCONVERTER_PROPERTY(escSharpness,SHP) CASE_SET_SCANCONVERTER_PROPERTY(escHwOutputHorzOffsShadow, HOHOS) CASE_SET_SCANCONVERTER_PROPERTY(escHwOutputVertOffsShadow, HOVOS) CASE_SET_SCANCONVERTER_PROPERTY(escTVPixels, TVP) CASE_SET_SCANCONVERTER_PROPERTY(escTVLines, TVL) CASE_SET_SCANCONVERTER_PROPERTY_DELAY(escHorizontalPositionOffset, HPO) CASE_SET_SCANCONVERTER_PROPERTY_DELAY(escVerticalPositionOffset, VPO)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?