📄 dcamdef.h
字号:
PDEVICE_OBJECT PhysicalDeviceObject;
//
// Holds the current generation count of the bus
//
ULONG CurrentGeneration;
//
// Holds the Configuration Rom for this device. Multi-functional
// devices (i.e. many units) will share this same Config Rom
// structure, but they are represented as a different Device Object.
// This is not the entire Config Rom, but does contain the root directory
// as well as everything in front of it.
//
PCONFIG_ROM ConfigRom;
//
// Holds the Unit Directory for this device. Even on multi-functional
// devices (i.e. many units) this should be unique to each Device Object.
//
PVOID UnitDirectory;
//
// Holds the Unit Dependent directory for this device.
//
PVOID UnitDependentDirectory;
//
// Holds the pointer to the Vendor Leaf information
//
PTEXTUAL_LEAF VendorLeaf;
PCHAR pchVendorName;
//
// Holds the pointer to the Model Leaf information
//
PTEXTUAL_LEAF ModelLeaf;
//
// Holds the Base Register of the camera (lower 32 bit portion only)
//
ULONG BaseRegister;
//
// Holds an area for us to read/write camera registers to/from here
//
union {
INITIALIZE_REGISTER Initialize;
V_FORMAT_INQ_REGISTER VFormat;
V_MODE_INQ_REGISTER VMode;
V_RATE_INQ_REGISTER VRate;
BRIGHTNESS_REGISTER Brightness;
WHITE_BALANCE_REGISTER WhiteBalance;
FEATURE_REGISTER Feature;
ULONG AsULONG;
} RegisterWorkArea;
//
// Holds what frame rate we'll display at
//
ULONG FrameRate;
//
// Holds the resource for the isoch stream we got
//
HANDLE hResource;
//
// Holds the bandwidth resource handle
//
HANDLE hBandwidth;
//
// Holds the Isoch channel we'll use to receive data
//
ULONG IsochChannel;
//
// Got this from the parent's PNODE_DEVICE_EXTENSION;
// Sinceit is from the 1394bus driver, it is safe to be used to set the xmit speed
//
ULONG SpeedCode;
//
// Holds the Mode Index that we currently supposed to be running at
//
ULONG CurrentModeIndex;
//
// Holds whether or not we need to listen (after we said we did)
// Used only if enable isoch streaming while no buffer is attached.
//
BOOLEAN bNeedToListen;
//
// Holds the list of isoch descriptors that are currently attached
//
LIST_ENTRY IsochDescriptorList;
//
// Holds the spin lock that must be acquired before playing around with
// the IsochDescriptorList
//
KSPIN_LOCK IsochDescriptorLock;
//
// Set to TRUE if isoch channel and resource have changed due to bus reset,
// and we must either resubmit the pending reads or cancel them.
//
BOOL bStopIsochCallback;
//
// Holds the number of reads down at any given moment
//
LONG PendingReadCount;
//
// The could be an array if the device support multiple streams. But we only has one capture pin.
//
struct _STREAMEX * pStrmEx;
//
// Many IEE 1394 cameras can use the same drivers. After a streamis open, this is incremented.
//
LONG idxDev;
//
// Query type of host controller and its capabilities (like stripe Quadlets)
//
GET_LOCAL_HOST_INFO2 HostControllerInfomation;
//
// Query the DMA capabilities; mainly to determine the max DMA buffer size
//
GET_LOCAL_HOST_INFO7 HostDMAInformation;
//
// Keep track of power state; know only D0 and D3
//
DEVICE_POWER_STATE CurrentPowerState;
//
// TRUE only after SRB_SURPRIESE_REMOVAL;
//
BOOL bDevRemoved;
//
// Pending work item
//
ULONG PendingWorkItemCount;
KEVENT PendingWorkItemEvent;
//
// Sometime the camera is not responding to our request;
// so we retied.
//
LONG lRetries; // [0.. RETRY_COUNT]
// ************************** //
// Streams: Formats and Modes //
// ************************** //
//
// Set in the INF to inform driver of what compression format
// (VMode) is supported by the decoder installed on the system (by default)
//
DCamRegArea DecoderDCamVModeInq0;
//
// cache the device's VFormat and VModeInq0 register values
//
DCamRegArea DCamVFormatInq;
DCamRegArea DCamVModeInq0;
//
// These values are retrun in the StreamHeader to advertise the stream formats supported.
//
ULONG ModeSupported; // 0..MAX_VMODE
PKSDATAFORMAT DCamStrmModes[MAX_VMODES];
// ************** //
// Device control //
// ************** //
#if DBG
//
// Inquire features supported be this device
//
DCamRegArea DevFeature1; //Brightness, Sharpness, WhiteBalance, Hue, Saturation..Focus...
DCamRegArea DevFeature2; // Zoom, Pan, Tilt...
#endif
//
// Property sets; when sets are in contiguous memory, they forma a property table.
//
ULONG ulPropSetSupported; // Number of property item supported.
KSPROPERTY_SET VideoProcAmpSet; // This is also the beginning of the property set table.
KSPROPERTY_SET CameraControlSet;
//
// Property items of what device supports
//
KSPROPERTY_ITEM DevPropItems[NUM_PROPERTY_ITEMS];
//
// Current settings defined (supported) by the device
//
DEV_PROPERTY_DEFINE DevPropDefine[NUM_PROPERTY_ITEMS];
//
// VideoProcAmp and CameraControl (range and current value)
//
DEV_PROPERTY DevProperty[NUM_PROPERTY_ITEMS];
//
// Global nonpaged pool memory used to read/write device register values (current value)
//
DCamRegArea RegArea;
//
// Global nonpaged pool memory used to read/write device register values (verify result)
//
DCamRegArea RegAreaVerify;
//
// Seralize using the global variables. (just in case we are called from multiple threads)
//
KMUTEX hMutexProperty;
} DCAM_EXTENSION, *PDCAM_EXTENSION;
//
// this structure is our per stream extension structure. This stores
// information that is relevant on a per stream basis. Whenever a new stream
// is opened, the stream class driver will allocate whatever extension size
// is specified in the HwInitData.PerStreamExtensionSize.
//
typedef struct _STREAMEX {
// Index to the table contain the data packet information
LONG idxIsochTable;
//
// Holds the master clock
//
HANDLE hMasterClock;
//
// Pointer to the data that i'm supposed to be working off of
//
PKS_VIDEOINFOHEADER pVideoInfoHeader;
//
// Statistic of the frame information since last start stream
//
KS_FRAME_INFO FrameInfo;
ULONGLONG FrameCaptured; // Number of frame return to the client
ULONGLONG FirstFrameTime; // Use to calculate drop frame
//
// Holds state
//
KSSTATE KSState;
KSSTATE KSStateFinal; // Final state that we want to reach using IoCompletion routine
KMUTEX hMutex; // MutEx of StreamIo or StreamControl, specifically setting to stop state.
//
// For Power Management; valid only in DCamChangePower()
//
KSSTATE KSSavedState;
//
// Hold a cancel token; 0==cancellable, 1==cancelling
//
ULONG CancelToken;
} STREAMEX, *PSTREAMEX;
typedef struct _CAMERA_ISOCH_INFO {
//
// Holds the number of quadlets in each Isochronous packet
//
ULONG QuadletPayloadPerPacket;
//
// Holds the speed required in order to receive this mode
//
ULONG SpeedRequired;
//
// Holds the size of a complete picture at this resolution and mode
//
ULONG CompletePictureSize;
} CAMERA_ISOCH_INFO, *PCAMERA_ISOCH_INFO;
typedef struct _ISOCH_DESCRIPTOR_RESERVED {
//
// Holds the list of descriptors that we have in use
//
LIST_ENTRY DescriptorList;
//
// Holds the pointer to the Srb that's associated with this descriptor
//
PHW_STREAM_REQUEST_BLOCK Srb;
//
// Holds the flags that we use to remember what state we're in
//
ULONG Flags;
} ISOCH_DESCRIPTOR_RESERVED, *PISOCH_DESCRIPTOR_RESERVED;
//
// Various definitions
//
#define FIELDOFFSET(type, field) (int)((INT_PTR)(&((type *)1)->field)-1)
#define QUERY_ADDR_OFFSET 0x0300 // 0x800 - 0x500 = 0x300
#define MAX_READ_REG_RETRIES 10 // Max retries until Pres is ready
#define NUM_POSSIBLE_RATES 6
#define RETRY_COUNT 5
#define RETRY_COUNT_IRP_SYNC 20
#define DEFAULT_FRAME_RATE 3
#define STOP_ISOCH_TRANSMISSION 0
#define START_ISOCH_TRANSMISSION 0x80
#define START_OF_PICTURE 1
#define MAX_BUFFERS_SUPPLIED 8
#define DCAM_DELAY_VALUE (ULONG)(-1 * 100 * 1000) // 10 ms
#define DCAM_DELAY_VALUE_BUSRESET (ULONG)(-1 * 2000 * 1000) // 200 ms
#define DCAM_REG_STABLE_DELAY (ULONG)(-1 * 500 * 1000) // 50 ms
#define ISO_ENABLE_BIT 0x00000080
//
// Definitions of the Frame Rate register located at offset 0x600
//
#define FRAME_RATE_0 0
#define FRAME_RATE_1 0x20
#define FRAME_RATE_2 0x40
#define FRAME_RATE_3 0x60
#define FRAME_RATE_4 0x80
#define FRAME_RATE_5 0xa0
#define FRAME_RATE_SHIFT 5
#define FORMAT_VGA_NON_COMPRESSED 0
#define ISOCH_CHANNEL_SHIFT 4
#define VIDEO_MODE_SHIFT 5
#define REGISTERS_TO_SET_TO_AUTO 10
#define STATE_SRB_IS_COMPLETE 1
#define STATE_DETACHING_BUFFERS 2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -