📄 camera_ms2.c.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.
Module Name:
CAMERA.c
**************************************************************************/
#include <windows.h>
#include <ceddk.h>
#include <types.h>
#include <string.h>
#include <stdio.h>
#include <tchar.h>
#include <nkintr.h>
#include <bulverde.h>
#include <mainstoneii.h>
#include "xllp_camera.h"
#include "camera_ms2.h"
#include "camera_ms2_api.h"
#include "xllp_ADCM2650.h"
extern PVOID VirtualAllocCopyPhysical(unsigned size,char *str,PVOID pPhysicalAddress);
volatile MAINSTONEII_BLR_REGS *v_pBoardLevelRegister;
P_CAMERA_APP_T pCameraApp;
// --- API begin ---
BOOL WINAPI CAM_Init(void)
{
v_pBoardLevelRegister=(volatile MAINSTONEII_BLR_REGS *)VirtualAllocCopyPhysical(sizeof(MAINSTONEII_BLR_REGS),"CAM_Init : v_pBoardLevelRegister",(PVOID)MAINSTONEII_BASE_REG_PA_FPGA);
if (!v_pBoardLevelRegister)
{
return FALSE;
}
return CameraInit();
}
BOOL WINAPI CAM_Deinit(DWORD dwData)
{
return CameraDeinit();
}
DWORD WINAPI CAM_Open(DWORD dwData, DWORD dwAccess, DWORD dwShareMode)
{
return (4);
}
BOOL WINAPI CAM_Close(DWORD dwData)
{
return (TRUE);
}
DWORD WINAPI CAM_Read(DWORD dwData, LPVOID pBuf, DWORD Len)
{
return (0);
}
DWORD WINAPI CAM_Write(DWORD dwData, LPCVOID pBuf, DWORD Len)
{
return (0);
}
DWORD WINAPI CAM_Seek(DWORD dwData, long pos, DWORD type)
{
return (DWORD)-1;
}
BOOL WINAPI CAM_IOControl(DWORD dwData, DWORD dwCode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut)
{
DWORD RetVal = TRUE;
switch(dwCode)
{
case CAMERA_INITIALIZE:
NKDbgPrintfW(TEXT("***** CAMERA_INITIALIZE\r\n"));
pCameraApp = (P_CAMERA_APP_T)pBufIn;
memset(&XllpCAMERA, 0, sizeof(XLLP_Camera_Context_T));
// capture image info
XllpCAMERA.capture_width = pCameraApp->VideoWidth;
XllpCAMERA.capture_height = pCameraApp->VideoHeight;
XllpCAMERA.Video_capture_width = pCameraApp->VideoWidth;
XllpCAMERA.Video_capture_height = pCameraApp->VideoHeight;
XllpCAMERA.Still_capture_width = pCameraApp->StillWidth;
XllpCAMERA.Still_capture_height = pCameraApp->StillHeight;
XllpCAMERA.light = pCameraApp->light;
XllpCAMERA.clkrc = pCameraApp->clkrc;
XllpCAMERA.gain = pCameraApp->gain;
XllpCAMERA.exposure = pCameraApp->exposure;
XllpCAMERA.sensor_flip_mode = XLLP_CAMERA_VIDEO_FLIP_VERTICAL | XLLP_CAMERA_VIDEO_FLIP_HORIZONTAL | XLLP_CAMERA_STILL_FLIP_HORIZONTAL;
switch (pCameraApp->CaptureFormat)
{
case FORMAT_PLANAR_422:
XllpCAMERA.capture_input_format = XLLP_CAMERA_IMAGE_FORMAT_YCBCR422_PACKED;
XllpCAMERA.capture_output_format = XLLP_CAMERA_IMAGE_FORMAT_YCBCR422_PLANAR;
XllpCAMERA.sensor_flip_mode = XLLP_CAMERA_STILL_FLIP_VERTICAL;
break;
case FORMAT_RGB:
XllpCAMERA.capture_input_format = XLLP_CAMERA_IMAGE_FORMAT_RGB888_PACKED;
XllpCAMERA.capture_output_format = XLLP_CAMERA_IMAGE_FORMAT_RGB555;
break;
default:
return FALSE;
}
// frame rate control
XllpCAMERA.frame_rate = pCameraApp->FrameRate;
// camera sensor specific information (Agilent ADCM2650)
XllpCAMERA.sensor_type = XLLP_CAMERA_TYPE_ADCM_2650;
pFunctions.init = CameraFuncADCM2650Init;
pFunctions.deinit = CameraFuncADCM2650DeInit;
pFunctions.set_capture_format = CameraFuncADCM2650SetCaptureFormat;
pFunctions.start_capture = CameraFuncADCM2650StartCapture;
pFunctions.stop_capture = CameraFuncADCM2650StopCapture;
// os mapped register address
XllpCAMERA.board_reg_base = (unsigned int)v_pBoardLevelRegister;
RetVal = CameraInitSensor();
break;
case CAMERA_START_VIDEO_CAPTURE:
NKDbgPrintfW(TEXT("***** CAMERA_START_VIDEO_CAPTURE\r\n"));
CameraStartVideoCapture();
RetVal = TRUE;
break;
case CAMERA_STOP_VIDEO_CAPTURE:
NKDbgPrintfW(TEXT("***** CAMERA_STOP_VIDEO_CAPTURE\r\n"));
CameraStopVideoCapture();
RetVal = TRUE;
break;
case CAMERA_CAPTURE_STILL_IMAGE:
NKDbgPrintfW(TEXT("***** CAMERA_CAPTURE_STILL_IMAGE\r\n"));
CameraCaptureStillImage();
break;
case CAMERA_WRITE_REGISTER:
NKDbgPrintfW(TEXT("***** CAMERA_WRITE_REGISTER\r\n"));
CameraWriteRegister(pCameraApp->subAddress, pCameraApp->bufP);
break;
case CAMERA_READ_REGISTER:
NKDbgPrintfW(TEXT("***** CAMERA_READ_REGISTER\r\n"));
CameraReadRegister(pCameraApp->subAddress, pCameraApp->bufP);
break;
case CAMERA_SHUTDOWN:
NKDbgPrintfW(TEXT("***** CAMERA_SHUTDOWN\r\n"));
RetVal = CameraShutdown();
break;
case CAMERA_CHANGE_CAPTURE_FORMAT:
NKDbgPrintfW(TEXT("***** CAMERA_CHANGE_CAPTURE_FORMAT\r\n"));
XllpCAMERA.Still_capture_width = pCameraApp->StillWidth;
XllpCAMERA.Still_capture_height = pCameraApp->StillHeight;
RetVal = CameraChangeCaptureFormat();
break;
case CAMERA_PREPARE_BUFFER:
// need to return a buffer id inside pBufOut
RetVal = CameraPrepareBuffer((P_CAMERA_DMA_BUFFER_INFO)pBufIn, VIDEO_CAPTURE_BUFFER);
break;
case CAMERA_UNPREPARE_BUFFER:
// RetVal = UnprepareBuffer((P_CAMERA_DMA_BUFFER_INFO)pBufIn);
break;
case CAMERA_SUBMIT_BUFFER:
CameraSubmitBuffer((P_CAMERA_DMA_BUFFER_INFO)pBufIn, VIDEO_CAPTURE_BUFFER);
RetVal = TRUE;
break;
case CAMERA_PREPARE_STILL_IMAGE_BUFFER:
RetVal = CameraPrepareBuffer((P_CAMERA_DMA_BUFFER_INFO)pBufIn, STILL_CAPTURE_BUFFER);
break;
case CAMERA_SUBMIT_STILL_IMAGE_BUFFER:
CameraSubmitBuffer((P_CAMERA_DMA_BUFFER_INFO)pBufIn, STILL_CAPTURE_BUFFER);
RetVal = TRUE;
break;
default:
break;
}
return (TRUE);
}
VOID WINAPI CAM_PowerUp (VOID)
{
//XllpI2cInit((P_XLLP_I2C_T)(v_pI2C), (P_XLLP_GPIO_T) v_pGPIORegs, (P_XLLP_CLKMGR_T) v_pClkRegs, (XLLP_UINT32_T) 0);
}
BOOL WINAPI CAM_PowerDown(VOID)
{
return (TRUE);
}
void WINAPI CAM_PowerHandler(BOOL bOff)
{
if(bOff)
{
CAM_PowerDown();
}
else
{
CAM_PowerUp();
}
}
BOOL WINAPI DllMain(HANDLE hInstDll,
DWORD dwReason,
LPVOID lpvReserved)
{
//
//Process the reason for calling the DLL's entry point
//
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return (TRUE);
}
// --- API end ---
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -