📄 tuner.cpp
字号:
case SRB_UNKNOWN_DEVICE_COMMAND:
pSrb->Status = STATUS_NOT_IMPLEMENTED;
break;
case SRB_OPEN_DEVICE_INSTANCE:
DbgLogInfo(("Receiving SRB_OPEN_DEVICE_INSTANCE -- SRB=%x, %d\n", pSrb, pSrb->CommandData.FilterTypeIndex));
break;
case SRB_CLOSE_DEVICE_INSTANCE:
DbgLogInfo(("Receiving SRB_CLOSE_DEVICE_INSTANCE -- SRB=%x, %d\n", pSrb, pSrb->CommandData.FilterTypeIndex));
break;
case SRB_PAGING_OUT_DRIVER:
TunerPageOut( pSrb );
break;
default:
DbgLogWarn(( "TunerReceivePacket( <other> 0x%08X )\n", pSrb->Command ));
pSrb->Status = STATUS_NOT_IMPLEMENTED;
break;
}
// Indicate back to the Stream Class that we're done with this SRB
TunerCompleteDeviceSrb( pSrb );
// See if there's anything else on the queue
Busy = RemoveFromListIfAvailable (
&pSrb,
&pTunerDataExt->ksSpinLock,
&pTunerDataExt->bProcessingAdapterSRB,
&pTunerDataExt->leSrbQueueHead);
if (!Busy)
{
break; // queue is empty
}
}
}
/*++ ********************************************************************\
*
* Function:
*
* void TunerCancelPacket( PHW_STREAM_REQUEST_BLOCK pSrb )
*
* Purpose:
*
* Return SRB status as cancelled
*
* Return:
*
* none
*
* History:
*
*
\******************************************************************** --*/
void STREAMAPI TunerCancelPacket( PHW_STREAM_REQUEST_BLOCK pSrb )
{
pSrb->Status = STATUS_CANCELLED;
}
/*++ ********************************************************************\
*
* Function:
*
* void TunerTimeoutPacket( PHW_STREAM_REQUEST_BLOCK pSrb )
*
* Purpose:
*
* Return SRB status as success
*
* Return:
*
* none
*
* History:
*
*
\******************************************************************** --*/
void STREAMAPI TunerTimeoutPacket( PHW_STREAM_REQUEST_BLOCK pSrb )
{
pSrb->Status = STATUS_SUCCESS;
}
/*++ ********************************************************************\
*
* Function:
*
* void PauseExecution( LONG ms )
*
* Purpose:
*
* Waits for ms (milliseconds).
*
* Return:
*
* none
*
* History:
*
*
\******************************************************************** --*/
void PauseExecution ( IN LONG ms )
{
LARGE_INTEGER Interval;
// Convert the input interval from units of milliseconds to units
// of 100ns.
Interval.QuadPart = (LONGLONG)(ms);
Interval.QuadPart *= 10000; // number of 100 ns intervals in 1 ms
Interval.QuadPart *= -1; // negative value indicates relative wait
// Tell the system to wait. KeDelayExecutionThread() is documented as
// the safe way to wait for extended periods (more than 50us).
NTSTATUS Status = KeDelayExecutionThread(
KernelMode,
FALSE,
&Interval );
}
/*++ ********************************************************************\
*
* Function:
*
* BOOL TunerSetTunerInput( PHW_STREAM_REQUEST_BLOCK pSrb,
* ULONG ulInputIndex )
*
* Purpose:
*
* For Philips 1236 tuner we'll use different I2C control
* bytes depending on which tuner input is selected.
* Both RF inputs on the 1236 tuner accept analog and digital video.
*
* Return:
*
*
*
* History:
*
*
\******************************************************************** --*/
void TunerSetTunerInput( PHW_STREAM_REQUEST_BLOCK pSrb )
{
NTSTATUS Status;
UNICODE_STRING UKeyName;
PTUNER_DATA_EXTENSION pTunerDataExt = (PTUNER_DATA_EXTENSION)pSrb->HwDeviceExtension;
HANDLE KeyHandle = OpenDriverKey( pTunerDataExt->realPDO );
DbgLogInfo(("TunerSetTunerInput\n"));
if (pTunerDataExt->ulTunerBrand == TUNER_BRAND_PHILIPS_1236D)
{
// for Philips 1236 tuner when the video input (1, 2) changes
// update the I2C control bytes.
DbgLogInfo(("Philips 1236 tuner\n"));
// set control bytes to new tuner input
TunerSetPhilips1236DCntrlBytes( pTunerDataExt );
// Since the Philips 1236 supports more than one tuner input for both
// analog video and digital video , save the tuner input in the registry
// so we can restore it next time we start up
PrepareKeyName( &UKeyName, "TunerInput", -1 );
Status = SetRegistryValue( KeyHandle,
&UKeyName,
REG_DWORD,
(PCHAR)&pTunerDataExt->ulTunerInput,
sizeof(ULONG) );
RtlFreeUnicodeString( &UKeyName );
if( NT_SUCCESS(Status) )
{
// Write succeeded
}
}
ZwClose( KeyHandle );
}
/*++ ********************************************************************\
*
* Function:
*
* void TunerSetPhilips1236DCntrlBytes( PHW_STREAM_REQUEST_BLOCK pSrb,
* ULONG ulTunerIndex )
*
* Purpose:
*
* Set the tuner low, mid, and high frequency bands
* into data extension depending on the Philips tuner mode
* and video input selection.
*
* Return:
*
* none
*
* History:
*
*
\******************************************************************** --*/
void TunerSetPhilips1236DCntrlBytes( PTUNER_DATA_EXTENSION pTunerDataExt )
{
DbgLogInfo(("TunerSetPhilips1236DCntrlBytes\n"));
// Tuner input number are zero based.
// NOTE:
//
// The Philips 1236D tuner accepts Analog TV and DTV on both tuner inputs.
//
// The Microsoft tuner filter dialog input number 1 (zero based = 0)
// is mapped to the outside connector of the tuner. Dialog input
// number 2 (zero base = 1) is mapped to the inside connector of the tuner.
if (pTunerDataExt->ulTunerInput == 1L && pTunerDataExt->ulTunerMode == KSPROPERTY_TUNER_MODE_TV)
{
// Analog video input inside connector
DbgLogInfo(("Tuner Input = inside connector, Tuner Mode = TV\n"));
pTunerDataExt->wTunerBandCtrlLow = kPhilips1236DTvInBandCtrlLow; // 0xCEA3
pTunerDataExt->wTunerBandCtrlMid = kPhilips1236DTvInBandCtrlMid; // 0xCE93
pTunerDataExt->wTunerBandCtrlHigh = kPhilips1236DTvInBandCtrlHigh; // 0xCE33
}
else if (pTunerDataExt->ulTunerInput == 0L && pTunerDataExt->ulTunerMode == KSPROPERTY_TUNER_MODE_TV)
{
// Analog video input outside connector
DbgLogInfo(("Tuner Input = outside connector, Tuner Mode = TV\n"));
pTunerDataExt->wTunerBandCtrlLow = kPhilips1236DTvOutBandCtrlLow; // 0xCEA2
pTunerDataExt->wTunerBandCtrlMid = kPhilips1236DTvOutBandCtrlMid; // 0xCE92
pTunerDataExt->wTunerBandCtrlHigh = kPhilips1236DTvOutBandCtrlHigh; // 0xCE32
}
else if (pTunerDataExt->ulTunerInput == 1L && pTunerDataExt->ulTunerMode == KSPROPERTY_TUNER_MODE_ATSC)
{
// ATSC video input inside connector
DbgLogInfo(("Tuner Input = inside connector, Tuner Mode = ATSC\n"));
pTunerDataExt->wTunerBandCtrlLow = kPhilips1236DATSCInBandCtrlLow; // 0xCEA0
pTunerDataExt->wTunerBandCtrlMid = kPhilips1236DATSCInBandCtrlMid; // 0xCE90
pTunerDataExt->wTunerBandCtrlHigh = kPhilips1236DATSCInBandCtrlHigh; // 0xCE30
}
else if (pTunerDataExt->ulTunerInput == 0L && pTunerDataExt->ulTunerMode == KSPROPERTY_TUNER_MODE_ATSC)
{
// ATSC video input outside connector
DbgLogInfo(("Tuner Input = outside connector, Tuner Mode = ATSC\n"));
pTunerDataExt->wTunerBandCtrlLow = kPhilips1236DATSCOutBandCtrlLow; // 0xCEA1
pTunerDataExt->wTunerBandCtrlMid = kPhilips1236DATSCOutBandCtrlMid; // 0xCE91
pTunerDataExt->wTunerBandCtrlHigh = kPhilips1236DATSCOutBandCtrlHigh;// 0xCE31
}
else
{
DbgLogError(("Tuner Input/Tuner Mode values error\n"));
return ;
}
}
/*++ ********************************************************************\
*
* Function:
*
* void TunerSetFreqBands( PHW_STREAM_REQUEST_BLOCK pSrb )
*
* Purpose:
*
* Set the tuner low, mid, and high frequency bands
* into data extension depending on the tuner brand
* (defined in the TunerBrand registry key).
*
* Return:
*
* none
*
* History:
*
*
\******************************************************************** --*/
void TunerSetFreqBands( PHW_STREAM_REQUEST_BLOCK pSrb )
{
PTUNER_DATA_EXTENSION pTunerDataExt = (PTUNER_DATA_EXTENSION)pSrb->HwDeviceExtension;
switch( pTunerDataExt->ulTunerBrand )
{
// TunerBrand registry value = 1
case TUNER_BRAND_TEMIC:
switch (pTunerDataExt->uiTunerType)
{
case TEMIC_4_IN_1:
pTunerDataExt->wTunerBandCtrlFM = kTemic4049BandCtrlFM;
pTunerDataExt->wTunerBandCtrlLow = kTemic4049BandCtrlLow;
pTunerDataExt->wTunerBandCtrlMid = kTemic4049BandCtrlMid;
pTunerDataExt->wTunerBandCtrlHigh = kTemic4049BandCtrlHigh;
break;
case TEMIC_4039: // supports FM
pTunerDataExt->wTunerBandCtrlFM = kTemic4039BandCtrlFM;
pTunerDataExt->wTunerBandCtrlLow = kTemic4039BandCtrlLow;
pTunerDataExt->wTunerBandCtrlMid = kTemic4039BandCtrlMid;
pTunerDataExt->wTunerBandCtrlHigh = kTemic4039BandCtrlHigh;
break;
case TEMIC_4136:
pTunerDataExt->wTunerBandCtrlLow = kTemic4136BandCtrlLow;
pTunerDataExt->wTunerBandCtrlMid = kTemic4136BandCtrlMid;
pTunerDataExt->wTunerBandCtrlHigh = kTemic4136BandCtrlHigh;
break;
default:
pTunerDataExt->wTunerBandCtrlLow = kTemicBandCtrlLow; // 0x8E02
pTunerDataExt->wTunerBandCtrlMid = kTemicBandCtrlMid; // 0x8E04
pTunerDataExt->wTunerBandCtrlHigh = kTemicBandCtrlHigh; // 0x8E01
break;
}
break;
// TunerBrand registry value = 2
case TUNER_BRAND_PHILIPS:
// TunerBrand registry value = 6
case TUNER_BRAND_XUGUANG:
switch (pTunerDataExt->uiTunerType)
{
case PHILIPS_FM1216_MK3: // Euro MK3 tuner with FM
case PHILIPS_FQ1216_MK3: // Euro MK3 tuner without FM
pTunerDataExt->wTunerBandCtrlLow = kPhilips1216InBandCtrlLow; // 0xCE08
pTunerDataExt->wTunerBandCtrlMid = kPhilips1216InBandCtrlMid; // 0xCE04
pTunerDataExt->wTunerBandCtrlHigh = kPhilips1216InBandCtrlHigh; // 0xCE02
pTunerDataExt->wTunerBandCtrlFM = kPhilips1216BandCtrlFM;
break;
case PHILIPS_FM1236_MK3: // NTSC MK3 tuner with FM
case PHILIPS_FQ1236_MK3: // NTSC MK3 tuner without FM
case PHILIPS_FI1236_MK3: // Economy NTSC MK3 tuner without FM
case PHILIPS_FM1286_MK3: // NTSC 1286 MK3 tuner with FM for Japan
pTunerDataExt->wTunerBandCtrlLow = kPhilips1236InBandCtrlLow; // 0xCE04
pTunerDataExt->wTunerBandCtrlMid = kPhilips1236InBandCtrlMid; // 0xCE02
pTunerDataExt->wTunerBandCtrlHigh = kPhilips1236InBandCtrlHigh; // 0xCE01
pTunerDataExt->wTunerBandCtrlFM = kPhilipsFM1236BandCtrlFM;
break;
case PHILIPS_FMD1216_ME:
pTunerDataExt->wTunerBandCtrlLow = kPhilipsFMD1216InBandCtrlLow; // 0x8651
pTunerDataExt->wTunerBandCtrlMid = kPhilipsFMD1216InBandCtrlMid; // 0x8652
pTunerDataExt->wTunerBandCtrlHigh = kPhilipsFMD1216InBandCtrlHigh; // 0x8654
pTunerDataExt->wTunerBandCtrlFM = kPhilipsFMD1216BandCtrlFM; // 0x8019
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -