Ryan Malloy bbdcb243dc Normalize line endings to LF across entire repository
Apply .gitattributes normalization to convert all CRLF line
endings inherited from Windows-origin source files to Unix LF.
175 files, zero content changes.
2026-02-20 10:55:50 -07:00

547 lines
19 KiB
C++

/*****************************************************************************
Company : Shree Ganesha Inc.
File Name : SkyWalker1AntennaPin.cpp
Author :
Date :
Purpose : This File Holds the Antenna Pin related declarations
Revision History:
===============================================================================
DATE VERSION AUTHOR REMARK
===============================================================================
XXth April,2009 01 Initial Version
*****************************************************************************/
/* Include the Library and Other header file */
#include "SkyWalker1Main.h" //Common For all the Definitions,
//Declarations and Library Routines
/* End of Inclusion the Library and Other header file */
/* Macro Definitions */
/* End of Macro Definitions */
/* Global & Static variables Declaration */
/* End of Global & Static variables Declaration */
/* External Variable Declaration */
/* End of External Variable Declaration */
/* Declare Enumerations here */
/* End of Enumeration declaration */
/* Function Prototypes */
PCHAR GetTunerPropertyString(ULONG ulTunerProperty);
PCHAR GetTunerLnbPropertyString(ULONG ulTunerLnbProperty);
/* End of Function prototype definitions */
/*****************************************************************************
Function : CAntennaPin::IntersectDataFormat
Description : Enables connection of the input pin with a upstream filter.
IN PARAM :
OUT PARAM : <NTSTATUS> Status of the IntersectDataFormat
PreCondition : None
PostCondtion : None
Logic : NONE
Assumption : NONE
Note : This is called from the PASSIVE_LEVEL_IRQL
Revision History: <REVISION HISTORY OF THE FUNCTION, MUST BE MAINTAINED BY MAINTAINER >
*****************************************************************************/
NTSTATUS CAntennaPin::IntersectDataFormat(
IN PVOID pContext,
IN PIRP pIoRequestPacket,
IN PKSP_PIN Pin,
IN PKSDATARANGE pDataRange,
IN PKSDATARANGE pMatchingDataRange,
IN ULONG ulDataBufferSize,
OUT PVOID pData OPTIONAL,
OUT PULONG pulDataSize
)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PrintFunctionEntry(__FUNCTION__);
if ( ulDataBufferSize < sizeof(KS_DATARANGE_BDA_ANTENNA) )
{
*pulDataSize = sizeof( KS_DATARANGE_BDA_ANTENNA );
ntStatus = STATUS_BUFFER_OVERFLOW;
goto ExitDataFormat;
}
else if (pDataRange->FormatSize < sizeof (KS_DATARANGE_BDA_ANTENNA))
{
ntStatus = STATUS_NO_MATCH;
goto ExitDataFormat;
}
else
{
*pulDataSize = sizeof( KS_DATARANGE_BDA_ANTENNA );
RtlCopyMemory( pData, (PVOID)pDataRange, sizeof(KS_DATARANGE_BDA_ANTENNA));
ntStatus = STATUS_SUCCESS;
}
ExitDataFormat:
PrintFunctionExit(__FUNCTION__,ntStatus);
return ntStatus;
}
/*****************************************************************************
Function : CAntennaPin::PinSetDeviceState
Description : An AVStream minidriver's AVStrMiniPinSetDeviceState
routine is called when the state of a KSPIN structure is
changed due to the arrival of a connection state property
'set' IOCTL. Typically, this will be provided by minidrivers
that need to change the state of hardware.
The KSSTATE enumeration lists possible states of a kernel
streaming object.
typedef enum {
KSSTATE_STOP;
KSSTATE_ACQUIRE;
KSSTATE_PAUSE;
KSSTATE_RUN;
} KSSTATE;
Enumerators
KSSTATE_STOP
Indicates that the object is in minimum resource consumption mode.
KSSTATE_ACQUIRE
Indicates that the object is acquiring resources.
KSSTATE_PAUSE
Indicates that the object is preparing to make instant transition to Run state.
KSSTATE_RUN
Indicates that the object is actively streaming.
Because the most upstream pin (input pin) is the last
to transition, use this pin's state to set the state
of the filter.
Also, release filter resouces if the pin's state
transitions to stop, and acquire resources if the pin's
state transitions from stop.
IN PARAM : <PKSPIN> Pointer to the KSPIN structure for which state is changing.
<KSSTATE> The target KSSTATE after receipt of the IOCTL.
<KSSTATE> The previous KSSTATE.
OUT PARAM : <NTSTATUS> Status of the PinSetDeviceState
PreCondition : None
PostCondtion : None
Logic : NONE
Assumption : NONE
Note : NONE
Revision History: <REVISION HISTORY OF THE FUNCTION, MUST BE MAINTAINED BY MAINTAINER >
*****************************************************************************/
NTSTATUS CAntennaPin::PinSetDeviceState(
IN PKSPIN pKSPin,
IN KSSTATE ToState,
IN KSSTATE FromState
)
{
NTSTATUS ntSetStatus = STATUS_SUCCESS;
PKSDEVICE pKSDevice = NULL;
CAntennaPin * pPin = NULL;
CSkyWalker1Device * pDevice = NULL;
PrintFunctionEntry(__FUNCTION__);
//Obtain a pointer to the device object from
//the passed in pointer to the KSPIN structure.
pKSDevice = KsPinGetDevice( pKSPin);
//Obtain a pointer to the pin object from context member of
//the passed in pointer to the KSPIN structure.
pPin = reinterpret_cast<CAntennaPin*>(pKSPin->Context);
//Obtain a pointer to the device object from context member of
//the retrieved pointer to the KSDEVICE structure.
pDevice = reinterpret_cast<CSkyWalker1Device *>(pKSDevice->Context);
pPin->m_pFilter->SetDeviceState( pPin->m_KsState);
if ((ToState == KSSTATE_STOP) && (FromState != KSSTATE_STOP))
{
//Because the driver allocates resources on a filter wide basis,
//inform the filter to release resources when the last pin
//(that is, the most upstream pin) transitions to the stop state.
//
//The input pin is the last pin to transition to the stop state,
//therefore inform the filter to release its resources.
//
ntSetStatus = pPin->m_pFilter->ReleaseResources();
pPin->m_KsState = ToState;
}
else if ((ToState == KSSTATE_ACQUIRE) && (FromState == KSSTATE_STOP))
{
//Because the driver allocates resources on a filter wide basis,
//inform the filter to acquire resources when the last pin
//(that is, the most upstream pin) transitions from the stop state.
//
//The input pin is the last pin to transition from the stop state,
//therefore inform the filter to acquire its resources.
//
ntSetStatus = pPin->m_pFilter->AcquireResources();
if (NT_SUCCESS( ntSetStatus))
{
pPin->m_KsState = ToState;
}
}
else if (ToState > KSSTATE_RUN)
{
SkyWalkerDebugPrint(EXTREME_LEVEL,
("Invalid Device State. ToState 0x%08x. FromState 0x%08x.",
ToState, FromState));
ntSetStatus = STATUS_INVALID_PARAMETER;
}
else
{
pPin->m_KsState = ToState;
}
PrintDeviceChangeState(ToState,FromState);
PrintFunctionExit(__FUNCTION__,ntSetStatus);
return ntSetStatus;
}
/*****************************************************************************
Function : CAntennaPin::GetTunerProperty
Description : Retrieves the value of the Tuner node Properties
IN PARAM : IN PIRP pIoRequestPacket,
IN PKSPROPERTY pKSProperty,
OUT PULONG pulProperty
OUT PARAM : <NTSTATUS> Status SUCCESS in case Valid Property request
STATUS_INVALID_PARAMETER in case of Invalid property request
Else error from the lower device
PreCondition : None
PostCondtion : Tuner propery read in case of successful execution
Logic : NONE
Assumption : NONE
Note : NONE
Revision History: <REVISION HISTORY OF THE FUNCTION, MUST BE MAINTAINED BY MAINTAINER >
*****************************************************************************/
NTSTATUS CAntennaPin::GetTunerProperty(
IN PIRP pIoRequestPacket,
IN PKSPROPERTY pKSProperty,
OUT PULONG pulProperty
)
{
NTSTATUS ntGetStatus = STATUS_SUCCESS;
CAntennaPin * pPin = NULL;
CTunerFilter* pFilter = NULL;
BDATUNER_DEVICE_PARAMETER TunerProperty;
PrintFunctionEntry(__FUNCTION__);
//Call the BDA support library to
//validate that the node type is associated with the pin.
//The BdaValidateNodeProperty function validates that a node property
//request is associated with a specific pin.
ntGetStatus = BdaValidateNodeProperty( pIoRequestPacket, pKSProperty);
if (NT_SUCCESS( ntGetStatus))
{
//Obtain a pointer to the pin object.
//Because the property dispatch table calls the CAntennaPin::GetTunerProperty()
//method directly, the method must retrieve a pointer to the underlying pin object.
pPin = reinterpret_cast<CAntennaPin *>(KsGetPinFromIrp(pIoRequestPacket)->Context);
//Retrieve the filter context from the pin context.
pFilter = pPin->GetFilter();
ntGetStatus = pFilter->GetTunerProperty(&TunerProperty);
//Retrieve the actual filter parameter.
switch (pKSProperty->Id)
{
case KSPROPERTY_BDA_RF_TUNER_FREQUENCY:
*pulProperty = TunerProperty.ulCarrierFrequency;
break;
case KSPROPERTY_BDA_RF_TUNER_FREQUENCY_MULTIPLIER:
*pulProperty = TunerProperty.ulFrequencyMultiplier;
break;
case KSPROPERTY_BDA_RF_TUNER_BANDWIDTH:
*pulProperty = TunerProperty.ulBandWidth;
break;
case KSPROPERTY_BDA_RF_TUNER_POLARITY:
*pulProperty = TunerProperty.Polarity;
break;
case KSPROPERTY_BDA_RF_TUNER_RANGE:
*pulProperty = TunerProperty.ulRange;
break;
case KSPROPERTY_BDA_RF_TUNER_TRANSPONDER:
*pulProperty = TunerProperty.ulTransponder;
break;
default:
ntGetStatus = STATUS_INVALID_PARAMETER;
break;
}
}
SkyWalkerDebugPrint(EXTREME_LEVEL,("Get : %s : %ul",GetTunerPropertyString(pKSProperty->Id),*pulProperty));
PrintFunctionExit(__FUNCTION__,ntGetStatus);
return ntGetStatus;
}
/*****************************************************************************
Function : CAntennaPin::SetTunerProperty
Description : Sets the value of the Tuner node Freq. Properties
IN PARAM : IN PIRP pIoRequestPacket,
IN PKSPROPERTY pKSProperty,
OUT PULONG pulProperty
OUT PARAM : <NTSTATUS> Status SUCCESS in case Valid Property request
STATUS_INVALID_PARAMETER in case of Invalid property request
Else error from the lower device
PreCondition : None
PostCondtion : Tuner Freq. property read in case of successful execution
Logic : NONE
Assumption : NONE
Note : NONE
Revision History: <REVISION HISTORY OF THE FUNCTION, MUST BE MAINTAINED BY MAINTAINER >
*****************************************************************************/
NTSTATUS CAntennaPin::SetTunerProperty(
IN PIRP pIoRequestPacket,
IN PKSPROPERTY pKSProperty,
IN PULONG pulProperty
)
{
NTSTATUS ntSetStatus = STATUS_SUCCESS;
CAntennaPin * pPin;
CTunerFilter* pFilter;
PrintFunctionEntry(__FUNCTION__);
//Call the BDA support library to
//validate that the node type is associated with the pin.
//The BdaValidateNodeProperty function validates that a node property
//request is associated with a specific pin.
ntSetStatus = BdaValidateNodeProperty( pIoRequestPacket, pKSProperty);
if (NT_SUCCESS( ntSetStatus))
{
//Obtain a pointer to the pin object.
//Because the property dispatch table calls the CAntennaPin::SetTunerProperty()
//method directly, the method must retrieve a pointer to the underlying pin object.
pPin = reinterpret_cast<CAntennaPin *>(KsGetPinFromIrp(pIoRequestPacket)->Context);
//Retrieve the filter context from the pin context.
pFilter = pPin->GetFilter();
SkyWalkerDebugPrint(EXTREME_LEVEL,("Set : %s : %lu\n",
GetTunerPropertyString(pKSProperty->Id),
*pulProperty));
//Retrieve the actual filter parameter.
switch (pKSProperty->Id)
{
case KSPROPERTY_BDA_RF_TUNER_FREQUENCY:
ntSetStatus = pFilter->SetFrequency(*pulProperty);
break;
case KSPROPERTY_BDA_RF_TUNER_FREQUENCY_MULTIPLIER:
ntSetStatus = pFilter->SetMultiplier(*pulProperty);
break;
case KSPROPERTY_BDA_RF_TUNER_BANDWIDTH:
ntSetStatus = pFilter->SetBandwidth(*pulProperty);
break;
case KSPROPERTY_BDA_RF_TUNER_POLARITY:
ntSetStatus = pFilter->SetPolarity((Polarisation) *pulProperty);
break;
case KSPROPERTY_BDA_RF_TUNER_RANGE:
ntSetStatus = pFilter->SetRange(*pulProperty);
break;
case KSPROPERTY_BDA_RF_TUNER_TRANSPONDER:
ntSetStatus = pFilter->SetTransponder(*pulProperty);
break;
default:
ntSetStatus = STATUS_INVALID_PARAMETER;
break;
}
}
PrintFunctionExit(__FUNCTION__,ntSetStatus);
return ntSetStatus;
}
/*****************************************************************************
Function : CAntennaPin::GetTunerLnbProperty
Description : Retrieves the value of the Tuner Lnb node Properties
IN PARAM : IN PIRP pIoRequestPacket,
IN PKSPROPERTY pKSProperty,
OUT PULONG pulProperty
OUT PARAM : <NTSTATUS> Status SUCCESS in case Valid Property request
STATUS_INVALID_PARAMETER in case of Invalid property request
Else error from the lower device
PreCondition : None
PostCondtion : Tuner lnb propery read in case of successful execution
Logic : NONE
Assumption : NONE
Note : NONE
Revision History: <REVISION HISTORY OF THE FUNCTION, MUST BE MAINTAINED BY MAINTAINER >
*****************************************************************************/
NTSTATUS CAntennaPin::GetTunerLnbProperty(
IN PIRP pIoRequestPacket,
IN PKSPROPERTY pKSProperty,
OUT PULONG pulProperty
)
{
NTSTATUS ntGetStatus = STATUS_SUCCESS;
CAntennaPin * pPin;
CTunerFilter* pFilter;
BDATUNER_DEVICE_PARAMETER LnbProperty;
PrintFunctionEntry(__FUNCTION__);
//Call the BDA support library to
//validate that the node type is associated with the pin.
//The BdaValidateNodeProperty function validates that a node property
//request is associated with a specific pin.
ntGetStatus = BdaValidateNodeProperty( pIoRequestPacket, pKSProperty);
if (NT_SUCCESS( ntGetStatus))
{
//Obtain a pointer to the pin object.
//Because the property dispatch table calls the CAntennaPin::GetTunerProperty()
//method directly, the method must retrieve a pointer to the underlying pin object.
pPin = reinterpret_cast<CAntennaPin *>(KsGetPinFromIrp(pIoRequestPacket)->Context);
//Retrieve the filter context from the pin context.
pFilter = pPin->GetFilter();
ntGetStatus = pFilter->GetTunerProperty(&LnbProperty);
//Retrieve the actual filter parameter.
switch (pKSProperty->Id)
{
case KSPROPERTY_BDA_LNB_LOF_LOW_BAND:
*pulProperty = LnbProperty.ulLnbLowLOFrequency;
break;
case KSPROPERTY_BDA_LNB_LOF_HIGH_BAND:
*pulProperty = LnbProperty.ulLnbHighLOFrequency;
break;
case KSPROPERTY_BDA_LNB_SWITCH_FREQUENCY:
*pulProperty = LnbProperty.ulLnbSwitchFrequency;
break;
default:
ntGetStatus = STATUS_INVALID_PARAMETER;
break;
}
}
SkyWalkerDebugPrint(EXTREME_LEVEL,("Get : %s : %ul",GetTunerLnbPropertyString(pKSProperty->Id),*pulProperty));
PrintFunctionExit(__FUNCTION__,ntGetStatus);
return ntGetStatus;
}
/*****************************************************************************
Function : CAntennaPin::SetTunerLnbProperty
Description : Sets the value of the Tuner Lnb node Properties
IN PARAM : IN PIRP pIoRequestPacket,
IN PKSPROPERTY pKSProperty,
IN PULONG pulProperty
OUT PARAM : <NTSTATUS> Status SUCCESS in case Valid Property request
STATUS_INVALID_PARAMETER in case of Invalid property request
Else error from the lower device
PreCondition : None
PostCondtion : Tuner propery Set in case of successful execution
Logic : NONE
Assumption : NONE
Note : NONE
Revision History: <REVISION HISTORY OF THE FUNCTION, MUST BE MAINTAINED BY MAINTAINER >
*****************************************************************************/
NTSTATUS CAntennaPin::SetTunerLnbProperty(
IN PIRP pIoRequestPacket,
IN PKSPROPERTY pKSProperty,
IN PULONG pulProperty
)
{
NTSTATUS ntSetStatus = STATUS_SUCCESS;
CAntennaPin * pPin;
CTunerFilter* pFilter;
PrintFunctionEntry(__FUNCTION__);
//Call the BDA support library to
//validate that the node type is associated with the pin.
//The BdaValidateNodeProperty function validates that a node property
//request is associated with a specific pin.
ntSetStatus = BdaValidateNodeProperty( pIoRequestPacket, pKSProperty);
if (NT_SUCCESS( ntSetStatus))
{
//Obtain a pointer to the pin object.
//Because the property dispatch table calls the CAntennaPin::SetTunerProperty()
//method directly, the method must retrieve a pointer to the underlying pin object.
pPin = reinterpret_cast<CAntennaPin *>(KsGetPinFromIrp(pIoRequestPacket)->Context);
//Retrieve the filter context from the pin context.
pFilter = pPin->GetFilter();
SkyWalkerDebugPrint(EXTREME_LEVEL,("Set : %s : %lu(%l)",
GetTunerLnbPropertyString(pKSProperty->Id),
*pulProperty,
*((LONG*)(pulProperty))));
//Retrieve the actual filter parameter.
switch (pKSProperty->Id)
{
case KSPROPERTY_BDA_LNB_LOF_LOW_BAND:
ntSetStatus = pFilter->SetLowLOFrequency(*pulProperty);
break;
case KSPROPERTY_BDA_LNB_LOF_HIGH_BAND:
ntSetStatus = pFilter->SetHighLOFrequency(*pulProperty);
break;
case KSPROPERTY_BDA_LNB_SWITCH_FREQUENCY:
ntSetStatus = pFilter->SetSwitchFrequency(*pulProperty);
break;
default:
ntSetStatus = STATUS_INVALID_PARAMETER;
break;
}
}
PrintFunctionExit(__FUNCTION__,ntSetStatus);
return ntSetStatus;
}
PCHAR GetTunerPropertyString(ULONG ulTunerProperty)
{
switch(ulTunerProperty)
{
case KSPROPERTY_BDA_RF_TUNER_FREQUENCY:
return "KSPROPERTY_BDA_RF_TUNER_FREQUENCY";
case KSPROPERTY_BDA_RF_TUNER_POLARITY:
return "KSPROPERTY_BDA_RF_TUNER_POLARITY";
case KSPROPERTY_BDA_RF_TUNER_RANGE:
return "KSPROPERTY_BDA_RF_TUNER_RANGE";
case KSPROPERTY_BDA_RF_TUNER_TRANSPONDER:
return "KSPROPERTY_BDA_RF_TUNER_TRANSPONDER";
case KSPROPERTY_BDA_RF_TUNER_BANDWIDTH:
return "KSPROPERTY_BDA_RF_TUNER_BANDWIDTH";
case KSPROPERTY_BDA_RF_TUNER_FREQUENCY_MULTIPLIER:
return "KSPROPERTY_BDA_RF_TUNER_FREQUENCY_MULTIPLIER";
default:
return "KSPROPERTY_BDA_INVALID_PROPERTY";
}
}
PCHAR GetTunerLnbPropertyString(ULONG ulTunerLnbProperty)
{
switch(ulTunerLnbProperty)
{
case KSPROPERTY_BDA_LNB_LOF_LOW_BAND:
return "KSPROPERTY_BDA_LNB_LOF_LOW_BAND";
case KSPROPERTY_BDA_LNB_LOF_HIGH_BAND:
return "KSPROPERTY_BDA_LNB_LOF_HIGH_BAND";
case KSPROPERTY_BDA_LNB_SWITCH_FREQUENCY:
return "KSPROPERTY_BDA_LNB_SWITCH_FREQUENCY";
default:
return "KSPROPERTY_BDA_INVALID_PROPERTY";
}
}