📄 drv2user.cpp
字号:
/**********************************************************************
* DRV2USER.C
* User-defined source code to support DRV2002
*
* Copyright (C) 2000 NxtWave Communications, Inc.
*
* NOTE: This file must be edited to adapt the DRV2002 software to a
* user-specific platform and operating system.
*
* Rev 1.4 Jun 20 2001 14:54:02
* Updated agcData to match 3.0.2 format.
*
* Rev 1.3 May 17 2001 15:54:02
* Modified for flexible AGC and multiregister access fix.
*
* Rev 1.2 Apr 20 2001 18:27:18
* First Official Release Version
*
* Rev 1.0 Nov 29 2000 20:45:38
* Initial revision.
**********************************************************************/
/*
******************************************************************************
Includes
******************************************************************************
*/
#include "drv2user.h"
#include "drv2002.h"
//#define I2CDEBUG
//#define CSDEBUG
/*
******************************************************************************
Public Functions (not static)
******************************************************************************
*/
/* Notification Functions */
/**********************************************************************
*
* NxtSuspendThread
*
* Called by DRV2002 to insert a delay in the current thread
*
* Inputs:
* Data16 mSecTime - number of milliseconds to sleep
*
* Notes:
* This should be implemented as an operating system "sleep" with
* 1 mS resolution.
*
**********************************************************************/
void NxtSuspendThread( Data16 mSecTime )
{
LARGE_INTEGER Interval;
KIRQL originalIRQL,tempIRQL;
// Convert the input interval from units of milliseconds to units
// of 100ns.
// Insure we are at PASSIVE_LEVEL
originalIRQL = KeGetCurrentIrql();
if (originalIRQL != PASSIVE_LEVEL)
{
return;
}
Interval.QuadPart = (LONGLONG)(mSecTime);
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 );
}
/**********************************************************************
*
* NxtOnChannelLock
*
* Called by DRV2002 on detection of a Lock condition
*
* Inputs:
* void *pContext - identifies which NXT2002 instance called the function
*
* Notes:
* This is a callback function that is called from NxtStart(). The
* user may define any action that should take place when lock is
* detected.
*
**********************************************************************/
void NxtOnChannelLock( void *pContext ) {
PTUNER_DATA_EXTENSION pTunerDataExt = (PTUNER_DATA_EXTENSION)pContext;
DbgLogInfo(("NxtOnChannelLock()\n"));
pTunerDataExt->bDemodIsLocked = TRUE;
// send a message to the hdall file object now since we's ok on channel
if(!pTunerDataExt->pHDALL_Device && !pTunerDataExt->bAttemptedToOpenHDALL)
{
GetHDAllDevice(&pTunerDataExt->pHDALL_Device, &pTunerDataExt->pHDALL_File);
pTunerDataExt->bAttemptedToOpenHDALL = TRUE;
}
//If the request succeeded, notify HDALL of the change.
if(pTunerDataExt->pHDALL_Device)
{
HDALL_INTERFACE Interface;
KdPrint(("Sending the notify mesage since we are locked\n"));
Interface.Command = HDALL_COMMAND_NOTIFY;
Interface.Data.NotificationInfo.TunerMode = pTunerDataExt->ulTunerMode;
Interface.Data.NotificationInfo.Channel = pTunerDataExt->Channel;
SendHDALLCommand(&Interface, pTunerDataExt->pHDALL_Device);
}
} /* NxtOnChannelLock */
/**********************************************************************
*
* NxtOnChannelLoss
*
* Called by DRV2002 on detection of a Loss-Of-Lock condition
*
* Inputs:
* void *pContext - identifies which NXT2002 instance called the function
*
* Notes:
* This is a callback function that is called from NxtStart(). The
* user may define any action that should take place when loss is
* detected.
*
**********************************************************************/
void NxtOnChannelLoss( void *pContext ) {
PTUNER_DATA_EXTENSION pTunerDataExt = (PTUNER_DATA_EXTENSION)pContext;
DbgLogInfo(("NxtOnChannelLoss()\n"));
pTunerDataExt->bDemodIsLocked = FALSE;
} /* NxtOnChannelLoss */
/* Operating System Interface */
/**********************************************************************
*
* NxtInitCriticalSection
*
* Called by DRV2002 to create a mutual exclusion object
*
* Outputs:
* NxtCSHandle_t *pCs - handle assigned to the new critical section object
*
* Returns:
* non-zero for failure
* 0 for success
*
**********************************************************************/
Data8 NxtInitCriticalSection( PFAST_MUTEX pMutex ) {
ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
ExInitializeFastMutex(pMutex);
#ifdef CSDEBUG
DbgLogInfo(("NxtInitCriticalSection, pMutex = %x\n", pMutex));
#endif
return SUCCESS;
} /* NxtInitCriticalSection */
/**********************************************************************
*
* NxtDeleteCriticalSection
*
* Called by DRV2002 to delete a mutual exclusion object
*
* Inputs:
* NxtCSHandle_t cs - handle of the critical section object to be deleted
*
* Returns:
* non-zero for failure
* 0 for success
*
**********************************************************************/
Data8 NxtDeleteCriticalSection( PFAST_MUTEX pMutex ) {
#ifdef CSDEBUG
DbgLogInfo(("NxtDeleteCriticalSection(), pMutex = %x\n", &pMutex));
#endif
if ( !pMutex )
{
return FAILURE;
}
ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
ExFreePool(pMutex);
pMutex = NULL;
return SUCCESS;
} /* NxtDeleteCriticalSection */
/**********************************************************************
*
* NxtRequestCriticalSection
*
* Called by DRV2002 on entry to a critical section, when no blocking
* is allowed.
*
* Inputs:
* NxtCSHandle_t cs - handle of the critical section being requested
*
* Returns:
* non-zero for failure -- critical section is currently in use
* 0 for success -- critical section not held by another thread
*
* Notes:
* This function must return immediately, indicating whether or not
* the calling function has exclusive access to the critical section.
* Implement as a critical section entry with no wait.
*
**********************************************************************/
Data8 NxtRequestCriticalSection( PFAST_MUTEX pMutex ) {
DbgLogInfo(("NxtRequestCriticalSection(), pMutex = %x\n", pMutex ));
// NOTHING TO DO HERE ??
return SUCCESS;
} /* NxtRequestCriticalSection */
/**********************************************************************
*
* NxtWaitForCriticalSection
*
* Called by DRV2002 on entry to a critical section, when blocking
* is required.
*
* Inputs:
* NxtCSHandle_t cs - handle of the critical section being requested
*
* Returns:
* non-zero for failure
* 0 for success
*
* Notes:
* This function must block indefinitely, until the requested critical
* section is available.
* Implement as a critical section entry with infinite wait.
*
**********************************************************************/
Data8 NxtWaitForCriticalSection( PFAST_MUTEX pMutex ) {
#ifdef CSDEBUG
DbgLogInfo(("NxtWaitForCriticalSection(), pMutex = %x\n", pMutex));
#endif
if ( !pMutex )
{
return FAILURE;
}
ASSERT( KeGetCurrentIrql() < DISPATCH_LEVEL );
ExAcquireFastMutex(pMutex);
return SUCCESS;
} /* NxtWaitForCriticalSection */
/**********************************************************************
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -