📄 iocontrol.c
字号:
status = STATUS_SUCCESS;
break;
}
case IOCTL_GET_ERROR:
{
ULONG Channel=*(PULONG)Irp->AssociatedIrp.SystemBuffer;
if(InBufferSize!= sizeof(LONG) || OutBufferSize != sizeof(ULONG) || !CheckChannel(pDE, Channel))
{
status = STATUS_INVALID_PARAMETER;
break;
}
*(PULONG)Irp->AssociatedIrp.SystemBuffer=pDE->ExStat[Channel];
pDE->ExStat[Channel]=0;
Irp->IoStatus.Information = sizeof(ULONG);
status = STATUS_SUCCESS;
break;
}
case IOCTL_RESET:
{
if(InBufferSize!= 0 || OutBufferSize != 0)
{
status = STATUS_INVALID_PARAMETER;
break;
}
InitializeHardware(pDE);
Irp->IoStatus.Information = 0;
status = STATUS_SUCCESS;
break;
}
case IOCTL_CAPTURE_BITMAP:
{
PMDL pMdl;
ULONG lByteOffset;
ULONG lByteCount;
PVOID pVirtual;
PHYSICAL_ADDRESS Phy;
PULONG pPage;
ULONG reg_Page, reg_BaseOdd, reg_BaseEven, reg_Prot;
PAVE2K_BITMAP_PARA pBitmapPara;
if(pDE->bBitmapCaptureLock){
status = STATUS_DEVICE_BUSY;
Irp->IoStatus.Information = 0;
break;
}
pDE->bBitmapCaptureLock=TRUE;
pMdl=Irp->MdlAddress;
pBitmapPara=(PAVE2K_BITMAP_PARA)Irp->AssociatedIrp.SystemBuffer;
CaptureBitmap(pDE, pMdl, pBitmapPara);
ave2kInitOverlay(pDE);
Irp->IoStatus.Information = 0;
status = STATUS_SUCCESS;
pDE->bBitmapCaptureLock=FALSE;
break;
}
case IOCTL_USER_INFO:
{
PAVE2K_USERINFO pUserInfo=(PAVE2K_USERINFO)(Irp->AssociatedIrp.SystemBuffer);
if(InBufferSize != sizeof(AVE2K_USERINFO))
{
status = STATUS_INVALID_PARAMETER;
break;
}
if(pUserInfo->bWrite){
if(WriteUserInformation(pDE, pUserInfo->nOffset, pUserInfo->nLength, pUserInfo->Buf))
status = STATUS_SUCCESS;
else
status = STATUS_UNSUCCESSFUL;
Irp->IoStatus.Information = 0;
}
else{
if(OutBufferSize != sizeof(AVE2K_USERINFO))
{
status = STATUS_INVALID_PARAMETER;
break;
}
if(ReadUserInformation(pDE, pUserInfo->nOffset, pUserInfo->nLength, pUserInfo->Buf))
status = STATUS_SUCCESS;
else
status = STATUS_UNSUCCESSFUL;
Irp->IoStatus.Information = sizeof(AVE2K_USERINFO);
}
break;
}
case IOCTL_AUDIO_SOURCE:
{
PAVE2K_AUDIO_SOURCE pSource=(PAVE2K_AUDIO_SOURCE)Irp->AssociatedIrp.SystemBuffer;
ULONG AudioSource=pSource->Source;
if(! pDE->ExtraFunctions){
status = STATUS_NOT_IMPLEMENTED;
Irp->IoStatus.Information = 0;
break;
}
if(InBufferSize!=sizeof(AVE2K_VIDEO_SOURCE) || !CheckChannel(pDE, pSource->Channel))
{
status = STATUS_INVALID_PARAMETER;
break;
}
if(AudioSource==AVE2K_AUDIO_SRC_MIC)
SetAudioSource(pDE, AUDIOSOURCE_MIC);
else
if(AudioSource==AVE2K_AUDIO_SRC_LINE)
SetAudioSource(pDE, AUDIOSOURCE_LINE);
else{
status = STATUS_INVALID_PARAMETER;
break;
}
status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
break;
}
case IOCTL_AUDIO_MONITOR:
{
PAVE2K_AUDIO_MONITOR pMonitor=(PAVE2K_AUDIO_MONITOR)Irp->AssociatedIrp.SystemBuffer;
ULONG Enable=pMonitor->Enable;
if(! pDE->ExtraFunctions){
status = STATUS_NOT_IMPLEMENTED;
Irp->IoStatus.Information = 0;
break;
}
if(InBufferSize!=sizeof(AVE2K_AUDIO_MONITOR) || !CheckChannel(pDE, pMonitor->Channel))
{
status = STATUS_INVALID_PARAMETER;
break;
}
SetAudioMonitor(pDE, Enable);
status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
break;
}
case IOCTL_ALARM_INTERFACE:
{
PAVE2K_ALARM_CONFIG pConfig;
if(! pDE->ExtraFunctions){
status = STATUS_NOT_IMPLEMENTED;
Irp->IoStatus.Information = 0;
break;
}
if(InBufferSize==sizeof(AVE2K_ALARM_CONFIG)){
if(OutBufferSize!=0){
status = STATUS_INVALID_PARAMETER;
Irp->IoStatus.Information = 0;
break;
}
pConfig=(PAVE2K_ALARM_CONFIG)Irp->AssociatedIrp.SystemBuffer;
if(!CheckChannel(pDE, pConfig->Channel)){
status = STATUS_INVALID_PARAMETER;
Irp->IoStatus.Information = 0;
break;
}
if(pConfig->Config!=AVE2K_ALARMCFG_NO && pConfig->Config!=AVE2K_ALARMCFG_NC){
status = STATUS_INVALID_PARAMETER;
Irp->IoStatus.Information = 0;
break;
}
ConfigAlarmInterface(pDE, pConfig->Config);
status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
break;
}
else if(InBufferSize==sizeof(ULONG)){
if(OutBufferSize!=sizeof(ULONG)){
status = STATUS_INVALID_PARAMETER;
Irp->IoStatus.Information = 0;
break;
}
else{
*(PULONG)Irp->AssociatedIrp.SystemBuffer=GetAlarmStatus(pDE);
status = STATUS_SUCCESS;
Irp->IoStatus.Information = sizeof(ULONG);
break;
}
}
status = STATUS_INVALID_PARAMETER;
Irp->IoStatus.Information = 0;
break;
}
case IOCTL_COMPRESS_FRMRATE:
{
PAVE2K_COMPRESS_FRMRATE pFrameRate;
if(! pDE->ExtraFunctions){
status = STATUS_NOT_IMPLEMENTED;
Irp->IoStatus.Information = 0;
break;
}
if(InBufferSize!=sizeof(AVE2K_COMPRESS_FRMRATE) || OutBufferSize!=0){
status = STATUS_INVALID_PARAMETER;
Irp->IoStatus.Information = 0;
break;
}
pFrameRate=(PAVE2K_COMPRESS_FRMRATE)Irp->AssociatedIrp.SystemBuffer;
if(!CheckChannel(pDE, pFrameRate->Channel)){
status = STATUS_INVALID_PARAMETER;
Irp->IoStatus.Information = 0;
break;
}
pDE->nOnFrame[0]=(USHORT)pFrameRate->OnFrame;
pDE->nOffFrame[0]=(USHORT)pFrameRate->OffFrame;
pDE->nStuffLimit[0]=(75-(pDE->VideoDataRate[0])/46)*(pDE->nOffFrame[0]+1);
if(!pDE->bFirstVideo && pDE->DataReceiving[0])
SetCompressFrameRate(pDE, pFrameRate->OnFrame, pFrameRate->OffFrame);
status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
break;
}
case IOCTL_VIDEO_GAIN:
{
PAVE2K_VIDEO_GAIN pGain=(PAVE2K_VIDEO_GAIN)Irp->AssociatedIrp.SystemBuffer;
if(InBufferSize!=sizeof(AVE2K_VIDEO_GAIN) || OutBufferSize!=0 || !CheckChannel(pDE, pGain->Channel))
{
status = STATUS_INVALID_PARAMETER;
break;
}
SetVideoGain(pDE, pGain->Channel, pGain->Gain);
status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
break;
}
case IOCTL_LOGO:
{
PAVE2K_LOGO pLogo=(PAVE2K_LOGO)Irp->AssociatedIrp.SystemBuffer;
if(!pDE->Compress ||
InBufferSize!=sizeof(AVE2K_LOGO) || OutBufferSize!=0 ||
!CheckChannel(pDE, pLogo->Channel))
{
status = STATUS_INVALID_PARAMETER;
break;
}
if(pLogo->Enable){
BuildLogo(pDE, pLogo->Channel, pLogo->Logo, pLogo->XPos, pLogo->YPos);
if(pDE->DataReceiving[pLogo->Channel]){
//if it's open, close it firstly
//if(pDE->bLogoEnable[pLogo->Channel])
// ToggleLogo(pDE, pLogo->Channel);
LoadLogo(pDE, pLogo->Channel);
if(!pDE->bLogoEnable[pLogo->Channel])
ToggleLogo(pDE, pLogo->Channel);
}
pDE->bLogoEnable[pLogo->Channel]=TRUE;
}
else{
if(pDE->DataReceiving[pLogo->Channel] && pDE->bLogoEnable[pLogo->Channel])
ToggleLogo(pDE, pLogo->Channel);
pDE->bLogoEnable[pLogo->Channel]=FALSE;
}
status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
break;
}
#if(TARGET_DEVICE==TD_TEST)
case IOCTL_TRANSADDRESS:
{
PHYSICAL_ADDRESS NewBaseAddress ;
PULONG pAddress;
if(InBufferSize!=sizeof(ULONG) || OutBufferSize!=sizeof(ULONG)*2)
{
status = STATUS_INVALID_PARAMETER;
break;
}
pAddress=(PULONG)(Irp->AssociatedIrp.SystemBuffer);
if(*pAddress){
NewBaseAddress = MmGetPhysicalAddress((PVOID)*pAddress);
*pAddress = NewBaseAddress.LowPart;
}
else//recover original setting
*pAddress = VGAAddress;
*(pAddress+1) = (ULONG)pDE->PhyPortBase;
status = STATUS_SUCCESS;
Irp->IoStatus.Information = sizeof(ULONG)*2;
break;
}
#endif
case IOCTL_PORT_ACCESS:
{
PAVE2K_PORT pPort;
UCHAR c;
if(InBufferSize!=sizeof(AVE2K_PORT)){
status = STATUS_INVALID_PARAMETER;
break;
}
pPort=(PAVE2K_PORT)(Irp->AssociatedIrp.SystemBuffer);
if(pPort->bWrite==0){
if(OutBufferSize!=sizeof(ULONG)){
status = STATUS_INVALID_PARAMETER;
break;
}
c=READ_PORT_UCHAR((PUCHAR)(pPort->Port));
*(PULONG)Irp->AssociatedIrp.SystemBuffer=(ULONG)c;
Irp->IoStatus.Information = sizeof(ULONG);
}
else{
c=(UCHAR)(pPort->Byte);
WRITE_PORT_UCHAR((PUCHAR)(pPort->Port), c);
Irp->IoStatus.Information = 0;
}
status = STATUS_SUCCESS;
break;
}
case IOCTL_ALARM_OUTPUT:
{
int nOut;
Irp->IoStatus.Information = 0;
if(InBufferSize!=sizeof(ULONG)){
status = STATUS_INVALID_PARAMETER;
break;
}
if((pDE->ExtraFunctions&0x02)==0){
status = STATUS_NOT_IMPLEMENTED;
break;
}
nOut=*(PULONG)(Irp->AssociatedIrp.SystemBuffer);
SetAlarmOutput(pDE, (BOOLEAN)nOut);
status = STATUS_SUCCESS;
break;
}
case IOCTL_FRMADJ_MODE2:
{
if(InBufferSize!=sizeof(ULONG)){
status = STATUS_INVALID_PARAMETER;
break;
}
if(pDE->ExtraFunctions==0){
status = STATUS_NOT_IMPLEMENTED;
break;
}
pDE->bFrmAdjMode2=*(PULONG)(Irp->AssociatedIrp.SystemBuffer);
Irp->IoStatus.Information = 0;
status = STATUS_SUCCESS;
break;
}
case IOCTL_DATE_OSD:
{
AVE2K_OSD *pOsd;
ULONG* pOSDPosition;
int nResult;
if(InBufferSize!=sizeof(AVE2K_OSD)){
status = STATUS_INVALID_PARAMETER;
break;
}
if(OutBufferSize!=sizeof(ULONG))
{
status = STATUS_INVALID_PARAMETER;
break;
}
if((pDE->ExtraFunctions&0x02)==0){
status = STATUS_NOT_IMPLEMENTED;
break;
}
nVT=GetVideoType(pDE,0);
if(nVT==VIDEOTYPE_NONE)
pDE->VideoType[0]=pDE->nPreVideoType[0];
else
pDE->VideoType[0] =nVT;
pOsd=(PAVE2K_OSD)(Irp->AssociatedIrp.SystemBuffer);
nResult=SetOSD(pDE, pOsd->nMode, pOsd->Name, pOsd->pHanLib);
pOSDPosition=(PULONG)(Irp->AssociatedIrp.SystemBuffer);
*pOSDPosition=nResult;
Irp->IoStatus.Information = sizeof(ULONG);
if(nResult)
status = STATUS_SUCCESS;
else
status = STATUS_INVALID_PARAMETER;
break;
}
case IOCTL_MASK_WINDOW:
{
AVE2K_MASK_WINDOW *pMaskWindow;
int nResult;
int nWidth;
int nHeight;
if(InBufferSize!=sizeof(AVE2K_MASK_WINDOW)){
status = STATUS_INVALID_PARAMETER;
break;
}
if((pDE->ExtraFunctions&0x02)==0){
status = STATUS_NOT_IMPLEMENTED;
break;
}
pMaskWindow=(PAVE2K_MASK_WINDOW)(Irp->AssociatedIrp.SystemBuffer);
status = STATUS_INVALID_PARAMETER;
nWidth=pMaskWindow->nRight - pMaskWindow->nLeft;
nHeight=pMaskWindow->nBottom - pMaskWindow->nTop;
pDE->bOSDMaskEnable=(unsigned char)pMaskWindow->bEnable;
if(pMaskWindow->bEnable){
if(nWidth>180)
break;
if(nHeight>288)
break;
pDE->nOSDMaskLeft=pMaskWindow->nLeft;
pDE->nOSDMaskRight=pMaskWindow->nRight;
pDE->nOSDMaskTop=pMaskWindow->nTop;
pDE->nOSDMaskBottom=pMaskWindow->nBottom;
AdjustOSDOffset(pDE);
}
nResult=SetMaskWindow(pDE);
Irp->IoStatus.Information = 0;
if(nResult)
status = STATUS_SUCCESS;
else
status = STATUS_INVALID_PARAMETER;
break;
}
case IOCTL_DETECT_AUDIO:
{
int nThreshold;
int nReturn;
int nReport;
ULONG nBuf1,n1,n2,n3,n4,nAve;
if(InBufferSize!=sizeof(unsigned long) && OutBufferSize!=sizeof(unsigned long)){
status = STATUS_INVALID_PARAMETER;
break;
}
if(InBufferSize==sizeof(unsigned long) && OutBufferSize==sizeof(unsigned long)){
status = STATUS_INVALID_PARAMETER;
break;
}
if(pDE->Double){//can't be done on XD
status = STATUS_NOT_IMPLEMENTED;
break;
}
if(InBufferSize==sizeof(unsigned long)){//set
nThreshold=*(PULONG)(Irp->AssociatedIrp.SystemBuffer);
pDE->nMaxAudio=0;
SetAudioMaxLevel(pDE, nThreshold);
}
else{//Get Audio Report
// SetAudioDetect();
// break;
n1=n2=n3=n4=0;
nBuf1=Ave2kReadRegister(pDE,0x144); //feedback buffer
n1=nBuf1&0xff;
n2=nBuf1&0xff00>>8;
n3=nBuf1&0xff0000>>16;
n4=nBuf1&0xff000000>>24;
if(n1==0xff)
{
n1=0;
}
if(n2==0xff)
{
n2=0;
}
if(n3==0xff)
{
n3=0;
}
if(n4==0xff)
{
n4=0;
}
nAve=(n1+n2+n3+n4)/4;
//nBuf2=Ave2kReadRegister(pDE,0x148);
if(pDE->bDataTSLRunnning){
if(pDE->nMaxAudio>pDE->lMaxLevel)
nReturn = pDE->nMaxAudio;
else
nReturn = 0;
pDE->nMaxAudio=0;
}
else{
nReport = Ave2kReadRegister(pDE, LEVEL_REP);
if(nReport&0x01)
{
if(pDE->nMaxAudio)
{
nReturn = pDE->nMaxAudio;
pDE->nMaxAudio=0;
}
else
nReturn = 1;
}
else
nReturn = 0;
}
*(PULONG)(Irp->AssociatedIrp.SystemBuffer) = nAve;//nReport;//nReturn;
}
Irp->IoStatus.Information = sizeof(ULONG);
status = STATUS_SUCCESS;
break;
}
//
// Not one we recognize. Error.
//
default:
status = STATUS_NOT_IMPLEMENTED;
Irp->IoStatus.Information = 0;
break;
}
//
// Get rid of this request
//
Irp->IoStatus.Status = status;
IoCompleteRequest( Irp, IO_NO_INCREMENT );
return status;
}
int CheckChannel(PDEVICE_EXTENSION pDE, ULONG Channel)
{
if(Channel>=2)
return FALSE;
if(!pDE->Double && Channel>=1)
return FALSE;
return TRUE;
}
//This function display an overlay window on screen by control SAA7146A
NTSTATUS ave2kOverlayControl(PDEVICE_EXTENSION pDE)
{
NTSTATUS status;
// ReInit7111(pDE);
if(ave2kInitOverlay(pDE))
status = STATUS_SUCCESS;
else
status = STATUS_SEVERITY_ERROR;
return status;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -