📄 device.cpp
字号:
sizeof(buf));
if ((NT_SUCCESS(Status)) && (buf))
{
if (stringsEqual(buf, L"svideo"))
{xbar->InputPins[0] = _XBAR_PIN_DESCRIPTION(KS_PhysConn_Video_SVideo, -1, &CrossbarMediums[2]);}
else if (stringsEqual(buf, L"tuner"))
{xbar->InputPins[0] = _XBAR_PIN_DESCRIPTION(KS_PhysConn_Video_Tuner, -1, &CrossbarMediums[1]);}
else if (stringsEqual(buf, L"composite"))
{xbar->InputPins[0] = _XBAR_PIN_DESCRIPTION(KS_PhysConn_Video_Composite, -1, &CrossbarMediums[0]);}
else if (stringsEqual(buf, L"none"))
{
TRAP();
}
else
{
TRAP();
}
}
else
{
TRAP();
}
// =========================
// Do MUX1
// =========================
Status = GetRegistryValue(handle,
MUX1String,
sizeof(MUX1String),
buf,
sizeof(buf));
if ((NT_SUCCESS(Status)) && (buf))
{
if (stringsEqual(buf, L"svideo"))
{xbar->InputPins[1] = _XBAR_PIN_DESCRIPTION(KS_PhysConn_Video_SVideo, -1, &CrossbarMediums[2]);}
else if (stringsEqual(buf, L"tuner"))
{xbar->InputPins[1] = _XBAR_PIN_DESCRIPTION(KS_PhysConn_Video_Tuner, -1, &CrossbarMediums[1]);}
else if (stringsEqual(buf, L"composite"))
{xbar->InputPins[1] = _XBAR_PIN_DESCRIPTION(KS_PhysConn_Video_Composite, -1, &CrossbarMediums[0]);}
else if (stringsEqual(buf, L"none"))
{
TRAP();
}
else
{
TRAP();
}
}
else
{
TRAP();
}
// =========================
// Do MUX2
// =========================
Status = GetRegistryValue(handle,
MUX2String,
sizeof(MUX2String),
buf,
sizeof(buf));
if ((NT_SUCCESS(Status)) && (buf))
{
if (stringsEqual(buf, L"svideo"))
{xbar->InputPins[2] = _XBAR_PIN_DESCRIPTION(KS_PhysConn_Video_SVideo, -1, &CrossbarMediums[2]);}
else if (stringsEqual(buf, L"tuner"))
{xbar->InputPins[2] = _XBAR_PIN_DESCRIPTION(KS_PhysConn_Video_Tuner, -1, &CrossbarMediums[1]);}
else if (stringsEqual(buf, L"composite"))
{xbar->InputPins[2] = _XBAR_PIN_DESCRIPTION(KS_PhysConn_Video_Composite, -1, &CrossbarMediums[0]);}
else if (stringsEqual(buf, L"none"))
{
TRAP();
}
else
{
TRAP();
}
}
else
{
TRAP();
}
// =========================
// 8 or 16 bit data width
// =========================
is16 = FALSE;
// =========================
// Control codes embedded in data stream?
// =========================
isCodeInDataStream = TRUE;
//Paul: If hardcoding, might as well leave this with the constructor
//defaultDecoderWidth = 720;
//
// close the registry handle.
//
ZwClose(handle);
} // status = success
}
BOOL Device::stringsEqual(PWCHAR pwc1, PWCHAR pwc2)
{
UNICODE_STRING us1, us2;
RtlInitUnicodeString(&us1, pwc1);
RtlInitUnicodeString(&us2, pwc2);
// case INsensitive
return (RtlEqualUnicodeString(&us1, &us2, TRUE));
}
// ==========================================
void Device::GetVideoPortProperty(PHW_STREAM_REQUEST_BLOCK pSrb)
{
PSTREAM_PROPERTY_DESCRIPTOR pSpd = pSrb->CommandData.PropertyInfo;
ULONG Id = pSpd->Property->Id; // index of the property
ULONG nS = pSpd->PropertyOutputSize; // size of data supplied
ULONG standard = GetVideoDecoderStandard();
switch (Id)
{
case KSPROPERTY_VPCONFIG_NUMCONNECTINFO :
ASSERT(nS >= sizeof(ULONG));
// 2 VideoPort connections are possible
*(PULONG)(pSpd->PropertyInfo) = BT829_VPCONNECTIONS_NUMBER;
pSrb->ActualBytesTransferred = sizeof(ULONG);
break;
case KSPROPERTY_VPCONFIG_GETCONNECTINFO :
ASSERT(nS >= sizeof(DDVIDEOPORTCONNECT));
{
PKSMULTIPLE_DATA_PROP MultiProperty = (PKSMULTIPLE_DATA_PROP)pSpd->Property;
if (MultiProperty->MultipleItem.Count == BT829_VPCONNECTIONS_NUMBER &&
MultiProperty->MultipleItem.Size == sizeof(DDVIDEOPORTCONNECT)) {
if (nS >= BT829_VPCONNECTIONS_NUMBER * sizeof(DDVIDEOPORTCONNECT)) {
LPDDVIDEOPORTCONNECT pConnectInfo;
pConnectInfo = (LPDDVIDEOPORTCONNECT) pSpd->PropertyInfo;
// fill in the DDVIDEOPORTCONNECT structure offset 0
pConnectInfo->dwSize = sizeof(DDVIDEOPORTCONNECT);
pConnectInfo->dwPortWidth = 8;
pConnectInfo->guidTypeID = DDVPTYPE_BROOKTREE;
pConnectInfo->dwFlags = DDVPCONNECT_INVERTPOLARITY;
pConnectInfo->dwReserved1 = 0;
#ifdef BT829_SUPPORT_16BIT
// fill in the DDVIDEOPORTCONNECT structure offset 1
pConnectInfo ++;
pConnectInfo->dwSize = sizeof(DDVIDEOPORTCONNECT);
pConnectInfo->guidTypeID = DDVPTYPE_BROOKTREE;
pConnectInfo->dwPortWidth = 16;
pConnectInfo->dwFlags = DDVPCONNECT_INVERTPOLARITY;
pConnectInfo->dwReserved1 = 0;
#endif
pSrb->ActualBytesTransferred = BT829_VPCONNECTIONS_NUMBER * sizeof(DDVIDEOPORTCONNECT);
}
else {
pSrb->Status = STATUS_INVALID_BUFFER_SIZE;
}
}
else {
pSrb->Status = STATUS_INVALID_PARAMETER;
}
}
break;
case KSPROPERTY_VPCONFIG_NUMVIDEOFORMAT :
ASSERT(nS >= sizeof(ULONG));
*(PULONG)(pSpd->PropertyInfo) = BT829_PIXELFORMATS_NUMBER;
pSrb->ActualBytesTransferred = sizeof(ULONG);
break;
case KSPROPERTY_VPCONFIG_GETVIDEOFORMAT :
ASSERT(nS >= sizeof(DDPIXELFORMAT));
{
PKSMULTIPLE_DATA_PROP MultiProperty = (PKSMULTIPLE_DATA_PROP)pSpd->Property;
if (MultiProperty->MultipleItem.Count == BT829_PIXELFORMATS_NUMBER &&
MultiProperty->MultipleItem.Size == sizeof(DDPIXELFORMAT)) {
if (nS >= BT829_PIXELFORMATS_NUMBER * sizeof(DDPIXELFORMAT)) {
ASSERT(BT829_PIXELFORMATS_NUMBER == 1); // as currently implemented, this must be true
LPDDPIXELFORMAT pPixelFormat;
pPixelFormat = (LPDDPIXELFORMAT) pSpd->PropertyInfo;
RtlZeroMemory(pPixelFormat, BT829_PIXELFORMATS_NUMBER * sizeof(DDPIXELFORMAT));
// fill in the DDPIXELFORMAT structure
pPixelFormat->dwSize = sizeof(DDPIXELFORMAT);
pPixelFormat->dwFlags = DDPF_FOURCC;
pPixelFormat->dwFourCC = FOURCC_UYVY;
pPixelFormat->dwYUVBitCount = 16;
pPixelFormat->dwYBitMask = (DWORD)0xFF00FF00;
pPixelFormat->dwUBitMask = (DWORD)0x000000FF;
pPixelFormat->dwVBitMask = (DWORD)0x00FF0000;
pPixelFormat->dwYUVZBitMask = 0;
pSrb->ActualBytesTransferred = BT829_PIXELFORMATS_NUMBER * sizeof(DDPIXELFORMAT);
}
else {
pSrb->Status = STATUS_INVALID_BUFFER_SIZE;
}
}
else {
pSrb->Status = STATUS_INVALID_PARAMETER;
}
}
break;
case KSPROPERTY_VPCONFIG_VPDATAINFO :
ASSERT(nS >= sizeof(KS_AMVPDATAINFO));
{
// Clear the portion of the buffer we plan to return
RtlZeroMemory(pSpd->PropertyInfo, sizeof(KS_AMVPDATAINFO));
PKS_AMVPDATAINFO pAMVPDataInfo;
pAMVPDataInfo = (PKS_AMVPDATAINFO) pSpd->PropertyInfo;
int decoderLostLines = (GetPartRev() >= 4) ?
BT829A_LOST_LINES : BT829_LOST_LINES;
// the values are sortof hardcoded for NTSC at this point
// VBI values will need to be tweaked
pAMVPDataInfo->dwSize = sizeof(KS_AMVPDATAINFO);
if ( standard & ( KS_AnalogVideo_NTSC_Mask | KS_AnalogVideo_PAL_M ) ) // NTSC rectangle?
pAMVPDataInfo->dwMicrosecondsPerField = 16667;
else
pAMVPDataInfo->dwMicrosecondsPerField = 20000;
pAMVPDataInfo->bEnableDoubleClock = FALSE;
pAMVPDataInfo->bEnableVACT = FALSE;
pAMVPDataInfo->lHalfLinesOdd = 0;
pAMVPDataInfo->lHalfLinesEven = 1;
pAMVPDataInfo->bFieldPolarityInverted = FALSE;
pAMVPDataInfo->bDataIsInterlaced = TRUE;
pAMVPDataInfo->dwNumLinesInVREF = 6 - decoderLostLines;
pAMVPDataInfo->amvpDimInfo.dwFieldWidth = GetDecoderWidth();
// Beware of hard-coded numbers
pAMVPDataInfo->amvpDimInfo.dwVBIWidth = VBISamples;
if ( standard & ( KS_AnalogVideo_NTSC_Mask | KS_AnalogVideo_PAL_M ) ) // NTSC rectangle?
{
pAMVPDataInfo->amvpDimInfo.dwVBIHeight = NTSCVBIEnd - decoderLostLines;
pAMVPDataInfo->amvpDimInfo.dwFieldHeight =
GetDecoderHeight() +
pAMVPDataInfo->amvpDimInfo.dwVBIHeight;
/*
(NTSCVBIEnd - 1) - // the '- 1' makes VBIEnd zero-based
decoderLostLines -
pAMVPDataInfo->dwNumLinesInVREF;
*/
pAMVPDataInfo->amvpDimInfo.rcValidRegion.top = NTSCVBIEnd - decoderLostLines;
}
else
{
pAMVPDataInfo->amvpDimInfo.dwVBIHeight = PALVBIEnd - decoderLostLines;
pAMVPDataInfo->amvpDimInfo.dwFieldHeight =
GetDecoderHeight() +
pAMVPDataInfo->amvpDimInfo.dwVBIHeight;
/*
(PALVBIEnd - 1) - // the '- 1' makes VBIEnd zero-based
decoderLostLines -
pAMVPDataInfo->dwNumLinesInVREF;
*/
pAMVPDataInfo->amvpDimInfo.rcValidRegion.top = PALVBIEnd - decoderLostLines;
}
pAMVPDataInfo->amvpDimInfo.rcValidRegion.left = 0;
pAMVPDataInfo->amvpDimInfo.rcValidRegion.right = pAMVPDataInfo->amvpDimInfo.dwFieldWidth;
pAMVPDataInfo->amvpDimInfo.rcValidRegion.bottom = pAMVPDataInfo->amvpDimInfo.dwFieldHeight;
pAMVPDataInfo->dwPictAspectRatioX = 4;
pAMVPDataInfo->dwPictAspectRatioY = 3;
pSrb->ActualBytesTransferred = sizeof(KS_AMVPDATAINFO);
}
break;
case KSPROPERTY_VPCONFIG_MAXPIXELRATE :
ASSERT(nS >= sizeof(KSVPMAXPIXELRATE));
{
PKSVPMAXPIXELRATE pKSPixelRate;
int decoderHeight = GetDecoderHeight();
int decoderWidth = GetDecoderWidth();
pKSPixelRate = (PKSVPMAXPIXELRATE) pSpd->PropertyInfo;
pKSPixelRate->Size.dwWidth = decoderWidth;
pKSPixelRate->Size.dwHeight = decoderHeight;
if ( standard & ( KS_AnalogVideo_NTSC_Mask | KS_AnalogVideo_PAL_M ) ) // NTSC rectangle?
pKSPixelRate->MaxPixelsPerSecond = decoderWidth * decoderHeight * NTSC_FRAME_RATE;
else
pKSPixelRate->MaxPixelsPerSecond = decoderWidth * decoderHeight * PAL_FRAME_RATE;
pKSPixelRate->Reserved = 0;
pSrb->ActualBytesTransferred = sizeof(KSVPMAXPIXELRATE);
}
break;
case KSPROPERTY_VPCONFIG_DECIMATIONCAPABILITY :
*(PBOOL)(pSpd->PropertyInfo) = TRUE;
pSrb->ActualBytesTransferred = sizeof(BOOL);
break;
default:
TRAP();
pSrb->ActualBytesTransferred = 0;
pSrb->Status = STATUS_NOT_IMPLEMENTED;
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -