📄 capprop.c
字号:
//==========================================================================;
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
// PURPOSE.
//
// Copyright (c) 1992 - 1996 Microsoft Corporation. All Rights Reserved.
//
//==========================================================================;
//
// This file handles all adapter property sets
//
#include "strmini.h"
#include "ksmedia.h"
#include "capmain.h"
#include "capdebug.h"
#include "capxfer.h"
#define DEFINE_MEDIUMS
#include "mediums.h"
// -------------------------------------------------------------------
// A few notes about property set handling
//
// Property sets used in Testcap are of two varieties, those that have
// default values, ranges, and stepping, such as VideoProcAmp and CameraControl,
// and those which don't have defaults and ranges, such as TVTuner and
// Crossbar.
//
// Default values and stepping are established by tables in capprop.h,
// no code is required to implement this other than initally creating the tables.
//
// Many of the property sets require the ability to modify a number
// of input parameters. Since KS doesn't allow this inherently, you'll
// note that some property sets require copying the provided input parameters
// to the ouput parameter list, effectively creating a "read, modify, write"
// capability. For this reason, the input and output parameter lists
// use identical structures.
//
// On an SRB_GET_DEVICE_PROPERTY, read-only input data to the driver is provided as:
// pSrb->CommandData.PropertyInfo
//
// ... while the output data pointer is:
// pSrb->CommandData.PropertyInfo.PropertyInfo
//
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// XBar pin definitions
// -------------------------------------------------------------------
typedef struct _XBAR_PIN_DESCRIPTION {
ULONG PinType;
ULONG SynthImageCommand; // This driver simulates different inputs by synthesizing images
ULONG RelatedPinIndex;
const KSPIN_MEDIUM *Medium; // Describes hardware connectivity
} XBAR_PIN_DESCRIPTION, *PXBAR_PIN_DESCRIPTION;
XBAR_PIN_DESCRIPTION XBarInputPins[] = {
// First list the video input pins, then the audio inputs, then the output pins
// Note that audio pin index 6 is shared between two video inputs (index 1 and index 2)
// PinType SynthImageCommand RelatedPinIndex Medium
/*0*/ KS_PhysConn_Video_Tuner, IMAGE_XFER_NTSC_EIA_100AMP_100SAT, 5, &CrossbarMediums[0],
/*1*/ KS_PhysConn_Video_Composite, IMAGE_XFER_NTSC_EIA_75AMP_100SAT, 6, &CrossbarMediums[1],
/*2*/ KS_PhysConn_Video_SVideo, IMAGE_XFER_BLACK, 6, &CrossbarMediums[2],
/*3*/ KS_PhysConn_Video_Tuner, IMAGE_XFER_WHITE, 7, &CrossbarMediums[3],
/*4*/ KS_PhysConn_Video_Composite, IMAGE_XFER_GRAY_INCREASING, 8, &CrossbarMediums[4],
/*5*/ KS_PhysConn_Audio_Tuner, 0, 0, &CrossbarMediums[5],
/*6*/ KS_PhysConn_Audio_Line, 0, 1, &CrossbarMediums[6],
/*7*/ KS_PhysConn_Audio_Tuner, 0, 3, &CrossbarMediums[7],
/*8*/ KS_PhysConn_Audio_Line, 0, 4, &CrossbarMediums[8],
};
#define NUMBER_OF_XBAR_INPUTS (SIZEOF_ARRAY (XBarInputPins))
XBAR_PIN_DESCRIPTION XBarOutputPins[] = {
// PinType SynthImageCommand RelatedPinIndex
/*0*/ KS_PhysConn_Video_VideoDecoder, 0, 1, &CrossbarMediums[9],
/*1*/ KS_PhysConn_Audio_AudioDecoder, 0, 0, &CrossbarMediums[10],
};
#define NUMBER_OF_XBAR_OUTPUTS (SIZEOF_ARRAY (XBarOutputPins))
#define NUMBER_OF_XBAR_PINS_TOTAL (NUMBER_OF_XBAR_INPUTS + NUMBER_OF_XBAR_OUTPUTS)
// -------------------------------------------------------------------
// XBar Property Set functions
// -------------------------------------------------------------------
/*
** AdapterSetCrossbarProperty ()
**
** Handles Set operations on the Crossbar property set.
** Testcap uses this to select an image to synthesize.
**
** Arguments:
**
** pSRB -
** Pointer to the HW_STREAM_REQUEST_BLOCK
**
** Returns:
**
** Side Effects: none
*/
VOID
STREAMAPI
AdapterSetCrossbarProperty(
PHW_STREAM_REQUEST_BLOCK pSrb
)
{
PHW_DEVICE_EXTENSION pHwDevExt = ((PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension);
PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
ULONG Id = pSPD->Property->Id; // index of the property
ULONG nS = pSPD->PropertyOutputSize; // size of data supplied
switch (Id) {
case KSPROPERTY_CROSSBAR_ROUTE: // W
{
PKSPROPERTY_CROSSBAR_ROUTE_S pRoute =
(PKSPROPERTY_CROSSBAR_ROUTE_S)pSPD->PropertyInfo;
ASSERT (nS >= sizeof (KSPROPERTY_CROSSBAR_ROUTE_S));
// Copy the input property info to the output property info
RtlCopyMemory( pRoute,
pSPD->Property,
sizeof (KSPROPERTY_CROSSBAR_ROUTE_S));
// Default to failure
pRoute->CanRoute = 0;
// if video
if (pRoute->IndexOutputPin == 0) {
if (pRoute->IndexInputPin <= 4) {
pHwDevExt->VideoInputConnected = pRoute->IndexInputPin;
pRoute->CanRoute = 1;
}
}
// if audio
else if (pRoute->IndexOutputPin == 1) {
// Special case! Audio Routing of (-1) means mute!!!
if (pRoute->IndexInputPin == -1) {
pHwDevExt->AudioInputConnected = pRoute->IndexInputPin;
pRoute->CanRoute = 1;
}
else if (pRoute->IndexInputPin > 4 && pRoute->IndexInputPin <= 8) {
pHwDevExt->AudioInputConnected = pRoute->IndexInputPin;
pRoute->CanRoute = 1;
}
}
// Somebody passed bogus data
if (pRoute->CanRoute == 0) {
pSrb->Status = STATUS_INVALID_PARAMETER;
}
}
break;
default:
TRAP;
break;
}
}
/*
** AdapterGetCrossbarProperty ()
**
** Handles Get operations on the Crossbar property set.
** Testcap uses this to select an image to synthesize.
**
** Arguments:
**
** pSRB -
** Pointer to the HW_STREAM_REQUEST_BLOCK
**
** Returns:
**
** Side Effects: none
*/
VOID
STREAMAPI
AdapterGetCrossbarProperty(
PHW_STREAM_REQUEST_BLOCK pSrb
)
{
PHW_DEVICE_EXTENSION pHwDevExt = ((PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension);
PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
ULONG Id = pSPD->Property->Id; // index of the property
ULONG nS = pSPD->PropertyOutputSize; // size of data supplied
switch (Id) {
case KSPROPERTY_CROSSBAR_CAPS: // R
{
PKSPROPERTY_CROSSBAR_CAPS_S pCaps =
(PKSPROPERTY_CROSSBAR_CAPS_S)pSPD->PropertyInfo;
if (nS < sizeof (KSPROPERTY_CROSSBAR_CAPS_S))
break;
// Copy the input property info to the output property info
RtlCopyMemory( pCaps,
pSPD->Property,
sizeof (KSPROPERTY_CROSSBAR_CAPS_S));
pCaps->NumberOfInputs = NUMBER_OF_XBAR_INPUTS;
pCaps->NumberOfOutputs = NUMBER_OF_XBAR_OUTPUTS;
pSrb->ActualBytesTransferred = sizeof (KSPROPERTY_CROSSBAR_CAPS_S);
}
break;
case KSPROPERTY_CROSSBAR_CAN_ROUTE: // R
{
PKSPROPERTY_CROSSBAR_ROUTE_S pRoute =
(PKSPROPERTY_CROSSBAR_ROUTE_S)pSPD->PropertyInfo;
if (nS < sizeof (KSPROPERTY_CROSSBAR_ROUTE_S))
break;
// Copy the input property info to the output property info
RtlCopyMemory( pRoute,
pSPD->Property,
sizeof (KSPROPERTY_CROSSBAR_ROUTE_S));
// Special case, audio output routed to (-1) means mute
if (pRoute->IndexOutputPin == 1 && pRoute->IndexInputPin == -1) {
pRoute->CanRoute = TRUE;
}
else if ((pRoute->IndexInputPin >= NUMBER_OF_XBAR_INPUTS) ||
(pRoute->IndexOutputPin >= NUMBER_OF_XBAR_OUTPUTS)) {
pRoute->CanRoute = FALSE;
}
else if ((pRoute->IndexInputPin <= 4) &&
(pRoute->IndexOutputPin == 0) ||
(pRoute->IndexInputPin >= 5) &&
(pRoute->IndexOutputPin == 1)) {
// This driver allows any video input to connect to any video output
// and any audio input to connect to any audio output
pRoute->CanRoute = TRUE;
}
else {
pRoute->CanRoute = FALSE;
}
pSrb->ActualBytesTransferred = sizeof (KSPROPERTY_CROSSBAR_ROUTE_S);
}
break;
case KSPROPERTY_CROSSBAR_PININFO: // R
{
PKSPROPERTY_CROSSBAR_PININFO_S pPinInfo =
(PKSPROPERTY_CROSSBAR_PININFO_S)pSPD->PropertyInfo;
if (nS < sizeof (KSPROPERTY_CROSSBAR_PININFO_S))
break;
// Copy the input property info to the output property info
RtlCopyMemory( pPinInfo,
pSPD->Property,
sizeof (KSPROPERTY_CROSSBAR_PININFO_S));
if (pPinInfo->Direction == KSPIN_DATAFLOW_IN) {
ASSERT (pPinInfo->Index < NUMBER_OF_XBAR_INPUTS);
pPinInfo->PinType = XBarInputPins[pPinInfo->Index].PinType;
pPinInfo->RelatedPinIndex = XBarInputPins[pPinInfo->Index].RelatedPinIndex;
pPinInfo->Medium = *XBarInputPins[pPinInfo->Index].Medium;
}
else {
ASSERT (pPinInfo->Index < NUMBER_OF_XBAR_OUTPUTS);
pPinInfo->PinType = XBarOutputPins[pPinInfo->Index].PinType;
pPinInfo->RelatedPinIndex = XBarOutputPins[pPinInfo->Index].RelatedPinIndex;
pPinInfo->Medium = *XBarOutputPins[pPinInfo->Index].Medium;
}
pPinInfo->Medium.Id = pHwDevExt->DriverMediumInstanceCount; // Multiple instance support
pSrb->ActualBytesTransferred = sizeof (KSPROPERTY_CROSSBAR_PININFO_S);
}
break;
case KSPROPERTY_CROSSBAR_ROUTE: // R
{
PKSPROPERTY_CROSSBAR_ROUTE_S pRoute =
(PKSPROPERTY_CROSSBAR_ROUTE_S)pSPD->PropertyInfo;
if (nS < sizeof (KSPROPERTY_CROSSBAR_ROUTE_S))
break;
// Copy the input property info to the output property info
RtlCopyMemory( pRoute,
pSPD->Property,
sizeof (KSPROPERTY_CROSSBAR_ROUTE_S));
// Sanity check
if (pRoute->IndexOutputPin >= NUMBER_OF_XBAR_OUTPUTS) {
pRoute->CanRoute = FALSE;
}
// querying the the video output pin
else if (pRoute->IndexOutputPin == 0) {
pRoute->IndexInputPin = pHwDevExt->VideoInputConnected;
pRoute->CanRoute = TRUE;
}
// querying the the audio output pin
else if (pRoute->IndexOutputPin == 1) {
pRoute->IndexInputPin = pHwDevExt->AudioInputConnected;
pRoute->CanRoute = TRUE;
}
pSrb->ActualBytesTransferred = sizeof (KSPROPERTY_CROSSBAR_ROUTE_S);
}
break;
default:
TRAP;
break;
}
}
// -------------------------------------------------------------------
// TVTuner Property Set functions
// -------------------------------------------------------------------
/*
** AdapterSetTunerProperty ()
**
** Handles Set operations on the TvTuner property set.
** Testcap uses this for demo purposes only.
**
** Arguments:
**
** pSRB -
** Pointer to the HW_STREAM_REQUEST_BLOCK
**
** Returns:
**
** Side Effects: none
*/
VOID
STREAMAPI
AdapterSetTunerProperty(
PHW_STREAM_REQUEST_BLOCK pSrb
)
{
PHW_DEVICE_EXTENSION pHwDevExt = ((PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension);
PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
ULONG Id = pSPD->Property->Id; // index of the property
ULONG nS = pSPD->PropertyOutputSize; // size of data supplied
switch (Id) {
case KSPROPERTY_TUNER_MODE:
{
PKSPROPERTY_TUNER_MODE_S pMode =
(PKSPROPERTY_TUNER_MODE_S)pSPD->Property;
ASSERT (pMode->Mode & (KSPROPERTY_TUNER_MODE_TV |
KSPROPERTY_TUNER_MODE_AM_RADIO |
KSPROPERTY_TUNER_MODE_FM_RADIO |
KSPROPERTY_TUNER_MODE_ATSC));
pHwDevExt->TunerMode = pMode->Mode;
}
break;
case KSPROPERTY_TUNER_STANDARD:
{
PKSPROPERTY_TUNER_STANDARD_S pStandard_S =
(PKSPROPERTY_TUNER_STANDARD_S) pSPD->Property;
pHwDevExt->VideoStandard = pStandard_S->Standard;
}
break;
case KSPROPERTY_TUNER_FREQUENCY:
{
PKSPROPERTY_TUNER_FREQUENCY_S pFreq_S =
(PKSPROPERTY_TUNER_FREQUENCY_S) pSPD->Property;
pHwDevExt->Frequency = pFreq_S->Frequency;
pHwDevExt->Country = pFreq_S->Country;
pHwDevExt->Channel = pFreq_S->Channel;
}
break;
case KSPROPERTY_TUNER_INPUT:
{
PKSPROPERTY_TUNER_INPUT_S pInput_S =
(PKSPROPERTY_TUNER_INPUT_S) pSPD->Property;
pHwDevExt->TunerInput = pInput_S->InputIndex;
}
break;
default:
TRAP;
break;
}
}
/*
** AdapterGetTunerProperty ()
**
** Handles Get operations on the TvTuner property set.
** Testcap uses this for demo purposes only.
**
** Arguments:
**
** pSRB -
** Pointer to the HW_STREAM_REQUEST_BLOCK
**
** Returns:
**
** Side Effects: none
*/
VOID
STREAMAPI
AdapterGetTunerProperty(
PHW_STREAM_REQUEST_BLOCK pSrb
)
{
PHW_DEVICE_EXTENSION pHwDevExt = ((PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension);
PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
ULONG Id = pSPD->Property->Id; // index of the property
ULONG nS = pSPD->PropertyOutputSize; // size of data supplied
PVOID pV = pSPD->PropertyInfo; // pointer to the output data
ASSERT (nS >= sizeof (LONG));
switch (Id) {
case KSPROPERTY_TUNER_CAPS:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -