camerapdd.cpp
来自「该BSP是基于PXA270+WINCE的BSP」· C++ 代码 · 共 176 行
CPP
176 行
//
// 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.
//
//
/******************************************************************************
** Copyright 2000-2003 Intel Corporation All Rights Reserved.
**
** Portions of the source code contained or described herein and all documents
** related to such source code (Material) are owned by Intel Corporation
** or its suppliers or licensors and is licensed by Microsoft Corporation for distribution.
** Title to the Material remains with Intel Corporation or its suppliers and licensors.
** Use of the Materials is subject to the terms of the Microsoft license agreement which accompanied the Materials.
** No other 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
** Some portion of the Materials may be copyrighted by Microsoft Corporation.
**
********************************************************************************/
#include <windows.h>
#include <types.h>
#include <string.h>
#include <stdio.h>
#include <tchar.h>
#include <ceddk.h>
#include <bulverde.h>
#include <mainstoneii.h>
#include <xllp_i2c.h>
extern "C" {
#include "ADCM2650.h"
}
#include "Cameradriver.h"
#include "CameraPdd.h"
extern "C"
int SensorInitPlatform(
P_XLLP_Camera_Context_T pCameraContext,
P_XLLP_Camera_DMA_Context_T pDmaContext
)
{
PHYSICAL_ADDRESS PA;
MAINSTONEII_BLR_REGS *pBLR;
RETAILMSG(1, (TEXT("CameraInitPlatform\r\n")));
// Mainstone II specific memory allocation
PA.QuadPart = MAINSTONEII_BASE_REG_PA_FPGA;
pBLR = (MAINSTONEII_BLR_REGS *) MmMapIoSpace(PA, sizeof(MAINSTONEII_BLR_REGS), FALSE);
if(pBLR)
{
// os mapped register address
pCameraContext->board_reg_base = (unsigned int)pBLR;
} else {
return FALSE;
}
// Camera sensor specific information (Agilent ADCM2650)
pCameraContext->sensor_type = XLLP_CAMERA_TYPE_ADCM_2650;
pCameraContext->camera_functions->init = CameraFuncADCM2650Init;
pCameraContext->camera_functions->deinit = CameraFuncADCM2650DeInit;
pCameraContext->camera_functions->set_capture_format = CameraFuncADCM2650SetCaptureFormat;
pCameraContext->camera_functions->start_capture = CameraFuncADCM2650StartCapture;
pCameraContext->camera_functions->stop_capture = CameraFuncADCM2650StopCapture;
// capture image info
pCameraContext->capture_width = DEFAULT_VIDEO_WIDTH;
pCameraContext->capture_height = DEFAULT_VIDEO_HEIGHT;
pCameraContext->Video_capture_width = DEFAULT_VIDEO_WIDTH;
pCameraContext->Video_capture_height = DEFAULT_VIDEO_HEIGHT;
pCameraContext->Video_capture_width = DEFAULT_VIDEO_WIDTH;
pCameraContext->Video_capture_height = DEFAULT_VIDEO_HEIGHT;
pCameraContext->Still_capture_width = DEFAULT_STILL_WIDTH;
pCameraContext->Still_capture_height = DEFAULT_STILL_HEIGHT;
pCameraContext->sensor_flip_mode = XLLP_CAMERA_VIDEO_FLIP_HORIZONTAL |
XLLP_CAMERA_STILL_FLIP_HORIZONTAL;
pCameraContext->capture_input_format = DEFAULT_CAMERA_INPUT_FORMAT;
pCameraContext->capture_output_format = DEFAULT_CAMERA_OUTPUT_FORMAT;
// Assign the DMA channels to camera sensor
pDmaContext->dma_channels[0] = XLLP_DMAC_CHANNEL_16;
pDmaContext->dma_channels[1] = XLLP_DMAC_CHANNEL_17;
pDmaContext->dma_channels[2] = XLLP_DMAC_CHANNEL_18;
return TRUE;
}
extern "C"
int SensorDeinitPlatform(
P_XLLP_Camera_Context_T pCameraContext,
P_XLLP_Camera_DMA_Context_T pDmaContext
)
{
pDmaContext->dma_channels[0] = (XLLP_DMAC_CHANNEL_T)0xFF;
pDmaContext->dma_channels[1] = (XLLP_DMAC_CHANNEL_T)0xFF;
pDmaContext->dma_channels[2] = (XLLP_DMAC_CHANNEL_T)0xFF;
if(pCameraContext->board_reg_base)
{
MmUnmapIoSpace((void *)pCameraContext->board_reg_base, sizeof(MAINSTONEII_BLR_REGS));
pCameraContext->board_reg_base = 0;
}
return TRUE;
}
int CameraInitPdd(void * pContext)
{
CCameraDevice *pCameraDevice = reinterpret_cast<CCameraDevice*>(pContext);
// Check the registry to see what format and number of pins we support.
HKEY hKey = NULL;
if(!pCameraDevice)
return false;
if ( ERROR_SUCCESS == RegOpenKeyEx( HKEY_LOCAL_MACHINE, L"Drivers\\Capture\\Mainstone_ii", 0, 0, &hKey ) )
{
DWORD dwType = 0;
DWORD dwSize = sizeof ( DWORD );
DWORD dwValue = 0;
// Find out if we should be using some other number of pins. The only
// valid options are 2 or 3. Default to 3.
if ( ERROR_SUCCESS == RegQueryValueEx( hKey, L"PinCount", 0, &dwType, (BYTE *)&dwValue, &dwSize ) )
{
if ( REG_DWORD == dwType
&& sizeof ( DWORD ) == dwSize
&& 2 == dwValue )
{
pCameraDevice->m_ulCTypes = 2;
}
else
{
pCameraDevice->m_ulCTypes = 3;
}
}
RegCloseKey( hKey );
}
// Video Format initialization
pCameraDevice->m_PinVideoFormat[CAPTURE].categoryGUID = PINNAME_VIDEO_CAPTURE;
pCameraDevice->m_PinVideoFormat[CAPTURE].ulAvailFormats = 1;
pCameraDevice->m_PinVideoFormat[CAPTURE].pCsDataRangeVideo[0] = &DCAM_StreamMode_0;
pCameraDevice->m_PinVideoFormat[STILL].categoryGUID = PINNAME_VIDEO_STILL;
pCameraDevice->m_PinVideoFormat[STILL].ulAvailFormats = 1;
pCameraDevice->m_PinVideoFormat[STILL].pCsDataRangeVideo[0] = &DCAM_StreamMode_0;
//pCameraDevice->m_PinVideoFormat[STILL].pCsDataRangeVideo[1] = &DCAM_StreamMode_1;
//pCameraDevice->m_PinVideoFormat[PREVIEW].categoryGUID = PINNAME_VIDEO_PREVIEW;
//pCameraDevice->m_PinVideoFormat[PREVIEW].ulAvailFormats = 1;
//pCameraDevice->m_PinVideoFormat[PREVIEW].pCsDataRangeVideo[0] = &DCAM_StreamMode_0;
// Video Control Caps
pCameraDevice->m_PinVideoCaps[CAPTURE].ulVideoControlCaps = DefaultVideoControlCaps[CAPTURE];
pCameraDevice->m_PinVideoCaps[STILL].ulVideoControlCaps = DefaultVideoControlCaps[STILL];
// Note PREVIEW and VIDEOPORT control caps are the same, so we don't differentiate
//pCameraDevice->m_PinVideoCaps[PREVIEW].ulVideoControlCaps = DefaultVideoControlCaps[PREVIEW];
return true;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?