?? pindriver.cpp.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.
//
/*++
Module Name:
PinDriver.cpp
Abstract:
Implementation of Pin subdevice for Intel PXA27x Mainstone II Direct Show camera driver.
Notes:
Revision History:
--*/
#include <windows.h>
#include <devload.h>
#include <nkintr.h>
#include <camera.h>
#include "CameraDriver.h"
#include "PinDriver.h"
EXTERN_C
DWORD
PIN_Init(
LPCTSTR Context,
LPVOID lpvBusContext
)
{
DEBUGMSG( ZONE_INIT, ( _T("PIN_Init: context %s\n"), Context ) );
PPININITHANDLE pPinInitDev = NULL;
if( OEM_CERTIFY_TRUST != CeGetCallerTrust() )
{
SetLastError(ERROR_ACCESS_DENIED);
}
else
{
pPinInitDev = new PININITHANDLE;
if ( NULL != pPinInitDev )
{
pPinInitDev->pCamDevice = reinterpret_cast<PCAMERADEVICE>( lpvBusContext );
if ( NULL == pPinInitDev->pCamDevice )
{
SetLastError( ERROR_INVALID_HANDLE );
SAFEDELETE( pPinInitDev );
DEBUGMSG( ZONE_INIT|ZONE_ERROR, ( _T("PIN_Init: Initialization Failed") ) );
}
}
else
{
SetLastError( ERROR_OUTOFMEMORY );
}
DEBUGMSG( ZONE_INIT, ( _T("PIN_Init: returning 0x%08x\r\n"), reinterpret_cast<DWORD>( pPinInitDev ) ) );
}
return reinterpret_cast<DWORD>( pPinInitDev );
}
EXTERN_C
BOOL
PIN_Deinit(
DWORD dwContext
)
{
DEBUGMSG( ZONE_INIT, ( _T("PIN_Deinit\r\n") ) );
PPININITHANDLE pPinInitDev = reinterpret_cast<PPININITHANDLE>( dwContext );
SAFEDELETE( pPinInitDev ) ;
return TRUE;
}
EXTERN_C
BOOL
PIN_IOControl(
DWORD dwContext,
DWORD Ioctl,
PUCHAR pInBufUnmapped,
DWORD InBufLen,
PUCHAR pOutBufUnmapped,
DWORD OutBufLen,
PDWORD pdwBytesTransferred
)
{
DEBUGMSG(ZONE_FUNCTION, ( _T("PIN_IOControl(%08x): IOCTL:0x%x, InBuf:0x%x, InBufLen:%d, OutBuf:0x%x, OutBufLen:0x%x)\r\n"), dwContext, Ioctl, pInBufUnmapped, InBufLen, pOutBufUnmapped, OutBufLen ) );
DWORD dwErr = ERROR_INVALID_PARAMETER;
BOOL bRc = FALSE;
PPINDEVICE pPinDevice = reinterpret_cast<PPINDEVICE>( dwContext );
UCHAR * pInBuf = NULL;
UCHAR * pOutBuf = NULL;
pInBuf = (UCHAR*) MapCallerPtr( pInBufUnmapped, InBufLen );
if (( pInBuf == NULL ) && ( pInBufUnmapped != NULL ))
{
DEBUGMSG( ZONE_IOCTL|ZONE_ERROR, ( _T("CAM_IOControl(%08x): CAM_IOControl. MapCallerPtr failed for incoming buffer.\r\n"), dwContext ) );
return dwErr;
}
pOutBuf = (UCHAR*) MapCallerPtr( pOutBufUnmapped, OutBufLen );
if (( NULL == pOutBuf ) && ( pOutBufUnmapped != NULL ))
{
DEBUGMSG( ZONE_IOCTL|ZONE_ERROR, ( _T("CAM_IOControl(%08x): CAM_IOControl. MapCallerPtr failed for incoming buffer.\r\n"), dwContext ) );
return dwErr;
}
if ( NULL == MapCallerPtr( pdwBytesTransferred, sizeof ( DWORD ) ) )
{
DEBUGMSG( ZONE_IOCTL|ZONE_ERROR, ( _T("PIN_IOControl(%08x): PIN_IOControl. MapCallerPtr failed for dwBytesTransferred.\r\n"), dwContext ) );
return dwErr;
}
switch ( Ioctl )
{
case IOCTL_CS_PROPERTY:
DEBUGMSG( ZONE_IOCTL, ( _T("PIN_IOControl(%08x): IOCTL_CS_PROPERTY\r\n"), dwContext ) );
__try
{
CSPROPERTY csProp = {0};
if ( ( NULL == pInBuf )
|| ( InBufLen < sizeof ( CSPROPERTY ) )
|| ( NULL == pdwBytesTransferred ) )
{
break;
}
if( !CeSafeCopyMemory( &csProp, pInBuf, sizeof( CSPROPERTY )))
{
break;
}
if ( TRUE == IsEqualGUID( csProp.Set, CSPROPSETID_Connection ) )
{
dwErr = pPinDevice->PinHandleConnectionRequests( &csProp, pOutBuf, OutBufLen, pdwBytesTransferred );
}
else if ( TRUE == IsEqualGUID( csProp.Set, CSPROPSETID_VPConfig ) )
{
dwErr = pPinDevice->PinHandleVPConfigRequests( &csProp, pOutBuf, OutBufLen, pdwBytesTransferred );
}
else
{
DEBUGMSG( ZONE_IOCTL|ZONE_ERROR, ( _T("PIN_IOControl(%08x): Unsupported PropertySet Request for IOCTL_CS_PROPERTY%u\r\n"), dwContext, csProp.Set ) );
dwErr = ERROR_NOT_SUPPORTED;
}
}
__except ( EXCEPTION_EXECUTE_HANDLER )
{
DEBUGMSG( ZONE_IOCTL, ( _T("PIN_IOControl(%08x):Exception in IOCTL_CS_PROPERTY"), dwContext ) );
}
break;
case IOCTL_CS_BUFFERS:
DEBUGMSG( ZONE_IOCTL, ( _T("PIN_IOControl(%08x): IOCTL_CS_BUFFERS\r\n"), dwContext ) );
__try
{
DWORD dwCommand;
if( ( NULL == pOutBuf )
|| ( NULL == pInBuf )
|| ( NULL == pdwBytesTransferred )
|| ( InBufLen < sizeof( DWORD ))
|| ( OutBufLen < sizeof( CS_STREAM_DESCRIPTOR ))
|| ( !CeSafeCopyMemory( &dwCommand, pInBuf, sizeof( DWORD ))))
{
if( pdwBytesTransferred )
{
*pdwBytesTransferred = sizeof( CS_STREAM_DESCRIPTOR );
}
DEBUGMSG( ZONE_IOCTL|ZONE_ERROR, ( _T("PIN_IOControl(%08x): IOCTL_CS_BUFFERS. Invalid parameters\r\n"), dwContext ) );
break;
}
dwErr = pPinDevice->PinHandleBufferRequest( dwCommand, pOutBuf, OutBufLen );
}
__except ( EXCEPTION_EXECUTE_HANDLER )
{
DEBUGMSG( ZONE_IOCTL, ( _T("PIN_IOControl(%08x):Exception in IOCTL_CS_BUFFERS"), dwContext ) );
}
break;
case IOCTL_STREAM_INSTANTIATE:
__try
{
DEBUGMSG( ZONE_IOCTL, ( _T("PIN_IOControl(%08x): IOCTL_STREAM_INSTANTIATE\r\n"), dwContext ) );
CSPROPERTY_STREAMEX_S csPropStreamEx = {0};
if ( ( NULL == pInBuf )
|| ( InBufLen < sizeof ( CSPROPERTY_STREAMEX_S ) )
|| ( NULL == pdwBytesTransferred ) )
{
DEBUGMSG( ZONE_IOCTL|ZONE_ERROR, ( _T("PIN_IOControl(%08x): IOCTL_STREAM_INSTANTIATE. Insufficient buffer\r\n"), dwContext ) );
break;
}
CeSafeCopyMemory( &csPropStreamEx, pInBuf, sizeof( CSPROPERTY_STREAMEX_S ));
if ( TRUE == IsEqualGUID( csPropStreamEx.CsPin.Property.Set, CSPROPSETID_StreamEx ) )
{
switch ( csPropStreamEx.CsPin.Property.Id )
{
case CSPROPERTY_STREAMEX_INIT:
dwErr = pPinDevice->StreamInstantiate( &csPropStreamEx, pOutBuf, OutBufLen, pdwBytesTransferred );
break;
default:
DEBUGMSG( ZONE_IOCTL|ZONE_ERROR, ( _T("PIN_IOControl(%08x): Invalid Request\r\n"), dwContext ) );
break;
}
}
else
{
DEBUGMSG( ZONE_IOCTL, ( _T("PIN_IOControl(%08x): Unsupported PropertySet Request for IOCTL_STREAM_INSTANTIATE%u\r\n"), dwContext, csPropStreamEx.CsPin.Property.Set ) );
dwErr = ERROR_NOT_SUPPORTED;
}
}
__except ( EXCEPTION_EXECUTE_HANDLER )
{
DEBUGMSG( ZONE_IOCTL|ZONE_ERROR, ( _T("PIN_IOControl(%08x):Exception in IOCTL_STREAM_INSTANTIATE"), dwContext ) );
}
break;
default:
DEBUGMSG( ZONE_IOCTL|ZONE_ERROR, ( _T("PIN_IOControl(%08x): Unsupported IOCTL code %u\r\n"), dwContext, Ioctl ) );
dwErr = ERROR_NOT_SUPPORTED;
break;
}
// pass back appropriate response codes
SetLastError(dwErr);
return ( ( dwErr == ERROR_SUCCESS ) ? TRUE : FALSE );
}
EXTERN_C
DWORD
PIN_Open(
DWORD Context,
DWORD Access,
DWORD ShareMode
)
{
DEBUGMSG( ZONE_FUNCTION, ( _T("PIN_Open(%x, 0x%x, 0x%x)\r\n"), Context, Access, ShareMode ) );
UNREFERENCED_PARAMETER( ShareMode );
UNREFERENCED_PARAMETER( Access );
// TODO : HANDLE ShareMode and Access parameters
PPININITHANDLE pPinInit = reinterpret_cast<PPININITHANDLE>( Context );
ASSERT( NULL != pPinInit );
PPINDEVICE pPinDevice = new PINDEVICE;
if ( NULL == pPinDevice )
{
DEBUGMSG( ZONE_FUNCTION, ( _T("PIN_Open(%x): Not enough memory to create pin device\r\n"), Context ) );
}
else
{
if ( false == pPinDevice->InitializeSubDevice( pPinInit->pCamDevice ) )
{
SAFEDELETE( pPinDevice );
DEBUGMSG( ZONE_INIT|ZONE_ERROR, ( _T("PIN_Init: Initialization Failed") ) );
}
}
return reinterpret_cast<DWORD>( pPinDevice );
}
EXTERN_C
BOOL
PIN_Close(
DWORD Context
)
{
DEBUGMSG( ZONE_FUNCTION, ( _T("PIN_Close(%x)\r\n"), Context ) );
PPINDEVICE pPinDev = reinterpret_cast<PPINDEVICE>( Context );
pPinDev->CloseSubDevice( );
SAFEDELETE( pPinDev );
return TRUE;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -