📄 bt8xxaccess.cpp
字号:
// This class represents our way to access the Hardware registers of the Bt8xx
#include "Bt8xxAccess.hpp"
// Bt8xx IDs
#define PCI_VENDOR_ID_BROOKTREE 0x109e
#define PCI_DEVICE_ID_BT848 0x350
#define PCI_DEVICE_ID_BT849 0x351
#define PCI_DEVICE_ID_BT878 0x36e
#define PCI_DEVICE_ID_BT879 0x36f
CBt8xxAccess::CBt8xxAccess() : dwPhysicalAddress(0) , dwMemoryBase(0)
{
// Try to load Dscaler driver
if (!DLL.Open(TEXT("DSDrv.dll"))) {
return;
}
// Get pointers to all the required fns.
static LPTSTR dTVFn[]={
TEXT("isDriverOpened"),
TEXT("pciGetHardwareResources"),
TEXT("memoryAlloc"),
TEXT("memoryFree"),
TEXT("memoryMap"),
TEXT("memoryUnmap"),
TEXT("memoryReadBYTE"),
TEXT("memoryReadWORD"),
TEXT("memoryReadDWORD"),
TEXT("memoryWriteBYTE"),
TEXT("memoryWriteWORD"),
TEXT("memoryWriteDWORD")
};
// dTV driver is loaded -- obtain entry points.
FARPROC *ppEntries = (FARPROC *)&dTVDrv;
for(int i=0; i<(sizeof dTVFn / sizeof dTVFn[0]); i++) {
if (!(ppEntries[i] = DLL.GetProcAddress(dTVFn[i]))) {
// Any failure will mean to abort here.
return;
}
}
// Map the registers...
DWORD ids[4][2]={
{ PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT848 },
{ PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT849 },
{ PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT878 },
{ PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT879 },
};
// Try each device in turn...
for(i=0; i<4; i++) {
// Try to find the card...
int ret = dTVDrv.pciGetHardwareResources(ids[i][0], ids[i][1], &dwPhysicalAddress,
&dwMemoryLength, &dwSubsystem);
if (ret == ERROR_SUCCESS) {
// Get the Memory base... And try to map it
dwMemoryBase = dTVDrv.memoryMap(dwPhysicalAddress, dwMemoryLength);
// If we were able to do so, break loop!
if (dwMemoryBase) {
// Remember the Chip version...
dwChip = ids[i][1];
dwRevision = 0; // Can't use dTV to get it...
break;
}
}
}
}
CBt8xxAccess::~CBt8xxAccess()
{
// Only uninit if we can/must...
if (DLL.IsOpen() && dTVDrv.memoryUnmap && dwPhysicalAddress) {
dTVDrv.memoryUnmap(dwPhysicalAddress,dwMemoryLength);
dwPhysicalAddress = NULL;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -