📄 cameradriver.h.svn-base
字号:
/**************************************************************************
** INTEL CONFIDENTIAL
** Copyright 2000-2004 Intel Corporation. All Rights Reserved.
**
** The source code contained or described herein and all documents
** related to the source code (Material) are owned by Intel Corporation
** or its suppliers or licensors. Title to the Material remains with
** Intel Corporation or its suppliers and licensors. The Material contains
** trade secrets and proprietary and confidential information of Intel
** or its suppliers and licensors. The Material is protected by worldwide
** copyright and trade secret laws and treaty provisions. No part of the
** Material may be used, copied, reproduced, modified, published, uploaded,
** posted, transmitted, distributed, or disclosed in any way without Intel抯
** prior express written permission.
** No license under any patent, copyright, trade secret or other intellectual
** property right is granted to or conferred upon you by disclosure or
** delivery of the Materials, either expressly, by implication, inducement,
** estoppel or otherwise. Any license under such intellectual property rights
** must be express and approved by Intel in writing.
********************************************************************************/
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
#ifndef __NULL_DD
#define __NULL_DD
#include <windows.h>
#include <ceddk.h>
#include "Cs.h"
#include "Csmedia.h"
#include <bulverde.h>
#include <mainstoneii.h>
extern "C" {
#include <xllp_camera.h>
#include <xllp_ADCM2650.h>
}
#ifndef DEBUG
#undef DEBUGMSG
#define DEBUGMSG RETAILMSG
#define ZONE_ERROR (1)
#define ZONE_WARN (1)
#define ZONE_INIT (1)
#define ZONE_FUNCTION (0)
#define ZONE_IOCTL (0)
#define ZONE_DEVICE (0)
#endif // DEBUG
#ifdef DEBUG
#define DEBUGMASK(bit) (1 << (bit))
#define MASK_ERROR DEBUGMASK(0)
#define MASK_WARN DEBUGMASK(1)
#define MASK_INIT DEBUGMASK(2)
#define MASK_FUNCTION DEBUGMASK(3)
#define MASK_IOCTL DEBUGMASK(4)
#define MASK_DEVICE DEBUGMASK(5)
#ifdef CAMINTERFACE
DBGPARAM dpCurSettings = {
_T("Camera"),
{
_T("Errors"), _T("Warnings"), _T("Init"), _T("Function"),
_T("Ioctl"), _T("Device"), _T("Activity"), _T(""),
_T(""),_T(""),_T(""),_T(""),
_T(""),_T(""),_T(""),_T("")
},
MASK_ERROR | MASK_WARN | MASK_INIT
};
#else
extern DBGPARAM dpCurSettings;
#endif
#define ZONE_ERROR DEBUGZONE(0)
#define ZONE_WARN DEBUGZONE(1)
#define ZONE_INIT DEBUGZONE(2)
#define ZONE_FUNCTION DEBUGZONE(3)
#define ZONE_IOCTL DEBUGZONE(4)
#define ZONE_DEVICE DEBUGZONE(5)
#endif
#define PIN_REG_PATH TEXT("Software\\Microsoft\\DirectX\\DirectShow\\Capture")
#define dim(x) (sizeof(x) / sizeof(x[0]))
#define SAFEDELETE( pointer ) \
if ( NULL != pointer ) \
{ \
delete pointer; \
pointer = NULL; \
}
#define MAX_SUPPORTED_PINS 3
#define MAX_PINNAME_LENGTH 10
#define MAX_VIDEO_FORMAT 2
#define NUM_VIDEOPROCAMP_ITEMS 10
#define NUM_CAMERACONTROL_ITEMS 8
#define NUM_PROPERTY_ITEMS NUM_VIDEOPROCAMP_ITEMS + NUM_CAMERACONTROL_ITEMS
#define MAX_HW_FRAMES 3
// Camera sensor default settings (should be synchronize with "adapterprops.h")
// Sensor h/w - Agilent ADCM2650
#define DEFAULT_VIDEO_WIDTH 176
#define DEFAULT_VIDEO_HEIGHT 144
#define DEFAULT_STILL_WIDTH 480
#define DEFAULT_STILL_HEIGHT 640
#define DEFAULT_CAMERA_INPUT_FORMAT (XLLP_CAMERA_IMAGE_FORMAT_RGB888_PACKED)
#define DEFAULT_CAMERA_OUTPUT_FORMAT (XLLP_CAMERA_IMAGE_FORMAT_RGB565)
// CAPTURE and STILL are required pin types. PREVIEW (or VIDEOPORT) is optional, so list it last.
enum
{
CAPTURE = 0,
STILL,
PREVIEW
};
static const WCHAR g_wszPinNames[MAX_SUPPORTED_PINS][MAX_PINNAME_LENGTH] = { L"Capture"
,L"Still"
,L"Preview"
};
static const WCHAR g_wszPinDeviceNames[MAX_SUPPORTED_PINS][MAX_PINNAME_LENGTH] = {L"PIN1:",
L"PIN1:",
L"PIN1:"};
typedef struct _Supported_Video_Formats
{
GUID categoryGUID;
ULONG ulAvailFormats;
PCS_DATARANGE_VIDEO pCsDataRangeVideo[ MAX_VIDEO_FORMAT ];
} PINVIDEOFORMAT, * PPINVIDEOFORMAT;
typedef struct _Dev_Property
{
ULONG ulDefaultValue;
ULONG ulCurrentValue;
ULONG ulFlags;
ULONG ulCapabilities;
PCSPROPERTY_VALUES pCsPropValues;
PCSPROPERTY_STEPPING_LONG pRangeNStep;
BOOL fGetSupported;
BOOL fSetSupported;
} DEV_PROPERTY, * PDEV_PROPERTY;
typedef struct _Video_Control_Caps
{
ULONG ulVideoControlCaps;
} VIDCONTROLCAPS, *PVIDCONTROLCAPS;
class CPinDevice;
typedef struct _StreamInstances
{
ULONG ulCInstances;
CSSTATE CsPrevState;
CPinDevice * pPinDev;
} STREAM_INSTANCES, * PSTREAM_INSTANCES;
typedef class CCameraDevice
{
public:
CCameraDevice( );
~CCameraDevice( );
bool
Initialize(
PVOID context
);
bool
BindApplicationProc(
HANDLE
);
bool
UnBindApplicationProc( );
DWORD
AdapterHandlePinRequests(
__in_bcount(InBufLen) PUCHAR pInBuf,
DWORD InBufLen,
__out_bcount(OutBufLen) PUCHAR pOutBuf,
DWORD OutBufLen,
PDWORD pdwBytesTransferred
);
DWORD
AdapterHandleVersion(
__out_bcount(OutBufLen) PUCHAR pOutBuf,
DWORD OutBufLen,
PDWORD pdwBytesTransferred
);
DWORD
AdapterHandleVidProcAmpRequests(
__in_bcount(InBufLen) PUCHAR pInBuf,
DWORD InBufLen,
__out_bcount(OutBufLen) PUCHAR pOutBuf,
DWORD OutBufLen,
PDWORD pdwBytesTransferred
);
DWORD
AdapterHandleCamControlRequests(
__in_bcount(InBufLen) PUCHAR pInBuf,
DWORD InBufLen,
__out_bcount(OutBufLen) PUCHAR pOutBuf,
DWORD OutBufLen,
PDWORD pdwBytesTransferred
);
DWORD
AdapterHandleCompressionRequests(
__in_bcount(InBufLen) PUCHAR pInBuf,
DWORD InBufLen,
__out_bcount(OutBufLen) PUCHAR pOutBuf,
DWORD OutBufLen,
PDWORD pdwBytesTransferred
);
DWORD
AdapterHandleVideoControlRequests(
__in_bcount(InBufLen) PUCHAR pInBuf,
DWORD InBufLen,
__out_bcount(OutBufLen) PUCHAR pOutBuf,
DWORD OutBufLen,
PDWORD pdwBytesTransferred
);
DWORD
AdapterHandleDroppedFramesRequests(
__in_bcount(InBufLen) PUCHAR pInBuf,
DWORD InBufLen,
__out_bcount(OutBufLen) PUCHAR pOutBuf,
DWORD OutBufLen,
PDWORD pdwBytesTransferred
);
LPVOID
ValidateBuffer(
__in_bcount(ulActualBufLen) LPVOID lpBuff,
ULONG ulActualBufLen,
ULONG ulExpectedBuffLen,
DWORD * dwError
);
bool
AdapterCompareFormat(
const ULONG ulPinId,
const PCS_DATARANGE_VIDEO pCsDataRangeVideoToCompare,
PCS_DATARANGE_VIDEO * ppCsDataRangeVideoMatched,
bool fDetailedComparison
);
bool
AdapterCompareFormat(
const ULONG ulPinId,
const PCS_DATAFORMAT_VIDEOINFOHEADER pCsDataRangeVideoToCompare,
PCS_DATARANGE_VIDEO * ppCsDataRangeVideoMatched,
bool fDetailedComparison
);
bool
IsValidPin(
ULONG ulPinId
);
bool
GetPinFormat(
ULONG ulPinId,
ULONG ulIndex,
PCS_DATARANGE_VIDEO * ppCsDataRangeVid
);
bool
GetZoom(
PULONG pulZoom
);
bool
GetBrightness(
PULONG pulBrightness
);
bool
IncrCInstances(
ULONG ulPinId,
CPinDevice * pPinDev
);
bool
DecrCInstances(
ULONG ulPinId
);
bool
PauseCaptureAndPreview( );
bool
RevertCaptureAndPreviewState( );
bool
StartHWCapture( );
bool
StopHWCapture( );
bool
CaptureHWStillImage( );
bool
GetCurrentHWBuffer (
ULONG ulPinId,
P_CAMERA_DMA_BUFFER_INFO pCamDmaBuffer
);
void
CameraHandleVideoFrame ( );
void
CameraHandleStillFrame ( );
private:
bool
AllocateHWBuffers (
ULONG ucBufferType
);
bool
DeAllocateHWBuffers (
ULONG ucBufferType
);
void
GetBasicSupportInfo(
__out_bcount(OutBufLen) PUCHAR pOutBuf,
DWORD OutBufLen,
PDWORD pdwBytesTransferred,
PDEV_PROPERTY pDevProp,
PDWORD pdwError
);
void
GetDefaultValues(
__out_bcount(OutBufLen) PUCHAR pOutBuf,
DWORD OutBufLen,
PDWORD pdwBytesTransferred,
PDEV_PROPERTY pDevProp,
PDWORD pdwError
);
bool
AdapterCompareGUIDsAndFormatSize(
const PCSDATARANGE DataRange1,
const PCSDATARANGE DataRange2
);
CRITICAL_SECTION m_csDevice;
HANDLE m_hStream; // Handle to the corresponding stream sub-device
HANDLE m_hCallerProcess;
PINVIDEOFORMAT m_PinVideoFormat[MAX_SUPPORTED_PINS];
VIDCONTROLCAPS m_PinVideoCaps[MAX_SUPPORTED_PINS];
ULONG m_ulCTypes;
STREAM_INSTANCES m_StrmInstances[MAX_SUPPORTED_PINS];
ULONG m_ulPropSetSupported; // Number of property item supported.
CSPROPERTY_SET m_VideoProcAmpSet; // This is also the beginning of the property set table.
CSPROPERTY_SET m_CameraControlSet;
//
// Property items of what device supports
//
CSPROPERTY_ITEM m_VideoProcAmpItems[NUM_VIDEOPROCAMP_ITEMS];
CSPROPERTY_ITEM m_CameraControlItems[NUM_CAMERACONTROL_ITEMS];
DEV_PROPERTY m_DevProps[NUM_PROPERTY_ITEMS];
bool m_bCameraHWRunning;
bool m_bNewFrameReady;
CAMERA_DMA_BUFFER_INFO m_CameraHWVideoBuffers[MAX_HW_FRAMES];
CAMERA_DMA_BUFFER_INFO m_CameraHWStillBuffer;
ULONG m_ulCurrentFrame;
HANDLE m_hCameraShutdownComplete;
// Mainstone II specific h/w resouces
volatile MAINSTONEII_BLR_REGS *m_vpBoardLevelRegister;
} CAMERADEVICE, * PCAMERADEVICE;
typedef struct CCameraOpenHandle
{
PCAMERADEVICE pCamDevice;
} CAMERAOPENHANDLE, * PCAMERAOPENHANDLE;
void CameraVideoFrameCallback ( DWORD dwContext );
void CameraStillFrameCallback ( DWORD dwContext );
#endif // __NULL_DD
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -