📄 camera.c
字号:
/*
* Alchemy Camera Interface (CIM) driver
*
* Copyright 2004-5 Advanced Micro Devices, Inc
*
*/
// Copyright (c) 2005 BSQUARE Corporation. All rights reserved.
/////////////////////////////////////////////////////////////
//
// ********************* TO DO LIST ************************
//
// - Allocate membuf in contiguous area?
// - Define IOCTL syntax and implement hooks.
// - Implement DMA interface. May need to modify DMA driver/library.
// - Implement interrupt interface. May need to modify kernel.
// - Do we need SMBus support library?
// - Get and convert AMD application OR write new test application.
//
/////////////////////////////////////////////////////////////
#include <windows.h>
#include <bceddk.h>
#include <ddkreg.h>
#include "platform.h"
extern BOOL HalStopMdlDMA(void*,ULONG*);
#include <smbus.h>
// Why is this part not in the header?
enum {
IOCTL_SMBUS_READDATA = 0x80002000, // some arbirary base
IOCTL_SMBUS_WRITEDATA
};
#include "camera.h"
#include "camera_hw.h"
#ifdef DEBUG
DBGPARAM dpCurSettings = {
L"Camera",
{L"Trace", L"Undefined", L"Undefined", L"Undefined",
L"Undefined", L"Undefined", L"Undefined", L"Undefined",
L"Undefined", L"Undefined", L"Undefined", L"Undefined",
L"Undefined", L"Power", L"Warning", L"Error",
},
0xC000
};
#endif // DEBUG
/*
Camera Interface Driver will always work in DBDMA Mode.
PIO Mode will result in OverFlow Error
*/
/*
* Global Variables
*/
AU1200_CIM *pCim = NULL; // Camera Interface Module
pBCSR pBcsr = NULL; // Board Registers
BOOL bInPowerHandler = FALSE;
/****************************************************************
* Configurations for Different Modes of Different Cameras
****************************************************************/
CAMERA CameraModes[] =
{
//////////////////////////////////////////////////////////////////////////
// Omnivision OV9640 Camera 1280x960 Mode (SXGA) in RAW 1.3 MP at 15 Fps
//////////////////////////////////////////////////////////////////////////
{
/* frame width */ 1280,
/* frame heigth */ 960,
/* camera name */ L"Omnivision",
/* camera mode */ L"raw_SXGA",
/* Cmos output format */ CMOS_RAW,
/* Resolution Format */ RAW_SXGA,
/* DPS mode */ CIM_CONFIG_RAW,
/* Bayer Mode */ CIM_CONFIG_BGGR,
/* dbdma channel */ 1,
/* Device Address */ 0x30,
/* No of Sub Register */ 50,
{
{0x12, 0x80},{0x12, 0x05},{0x11,0x80},{0x3b, 0x00},{0x33, 0x02},
{0x37, 0x02},{0x38, 0x13},{0x39,0xf0},{0x6c, 0x40},{0x6d, 0x30},
{0x6e, 0x4b},{0x6f, 0x60},{0x70,0x70},{0x71, 0x70},{0x74, 0x60},
{0x75, 0x60},{0x76, 0x50},{0x77,0x48},{0x78, 0x3a},{0x79, 0x2e},
{0x7a, 0x2a},{0x7b, 0x22},{0x7c,0x04},{0x7d, 0x07},{0x7e, 0x10},
{0x7f, 0x28},{0x80, 0x36},{0x81,0x44},{0x82, 0x52},{0x83, 0x60},
{0x84, 0x6c},{0x85, 0x78},{0x86,0x8c},{0x87, 0x9e},{0x88, 0xbb},
{0x89, 0xd2},{0x8a, 0xe6},{0x0f,0x4f},{0x3c, 0x40},{0x14, 0xca},
{0x42, 0x89},{0x24, 0x78},{0x25,0x68},{0x26, 0xd4},{0x27, 0x90},
{0x2a, 0x00},{0x2b, 0x00},{0x3d,0x80},{0x41, 0x00},{0x60, 0x8d},
}
},
//////////////////////////////////////////////////////////////////////////
// Omnivision OV9640 Camera 640x480 Mode (VGA) in "Pass Through Mode"
//////////////////////////////////////////////////////////////////////////
{
/* frame width */ 640,
/* frame heigth */ 480,
/* camera name */ L"Omnivision",
/* camera mode */ L"raw_VGA",
/* Cmos output format */ CMOS_RAW,
/* Resolution Format */ RAW_VGA,
/* DPS mode */ CIM_CONFIG_RAW,
/* Bayer Mode */ CIM_CONFIG_BGGR,
/* dbdma channel */ 1,
/* Device Address */ 0x30,
/* No of Sub Register */ 54,
{
{0x12, 0x80},{0x12, 0x45},{0x11,0x81},{0x0c, 0x04},{0x0d, 0x40},
{0x3b, 0x00},{0x33, 0x02},
{0x37, 0x02},{0x38, 0x13},{0x39,0xf0},{0x6c, 0x40},{0x6d, 0x30},
{0x6e, 0x4b},{0x6f, 0x60},{0x70,0x70},{0x71, 0x70},{0x72, 0x70},
{0x73, 0x70},{0x74, 0x60},
{0x75, 0x60},{0x76, 0x50},{0x77,0x48},{0x78, 0x3a},{0x79, 0x2e},
{0x7a, 0x28},{0x7b, 0x22},{0x7c,0x04},{0x7d, 0x07},{0x7e, 0x2e},
{0x7f, 0x28},{0x80, 0x36},{0x81,0x44},{0x82, 0x52},{0x83, 0x60},
{0x84, 0x6c},{0x85, 0x78},{0x86,0x8c},{0x87, 0x9e},{0x88, 0xbb},
{0x89, 0xd2},{0x8a, 0xe6},{0x0f,0x4f},{0x3c, 0x40},{0x14, 0xca},
{0x42, 0x89},{0x24, 0x78},{0x25,0x68},{0x26, 0xd4},{0x27, 0x90},
{0x2a, 0x00},{0x2b, 0x00},{0x3d,0x80},{0x41, 0x00},{0x60, 0x8d},
}
},
//////////////////////////////////////////////////////////////////////////
// Omnivision OV9640 Camera 352x280 Mode CIF "Pass Through Mode"
//////////////////////////////////////////////////////////////////////////
{
/* frame width */ 352,
/* frame heigth */ 288,
/* camera name */ L"Omnivision",
/* camera mode */ L"raw_CIF",
/* Cmos output format */ CMOS_RAW,
/* Resolution Format */ RAW_CIF,
/* DPS mode */ CIM_CONFIG_RAW,
/* Bayer Mode */ CIM_CONFIG_BGGR,
/* dbdma channel */ 1,
/* Device Address */ 0x30,
/* No of Sub Register */ 54,
{
{0x12, 0x80},{0x12, 0x25},{0x11,0x80},{0x0c, 0x04},{0x0d, 0x40},
{0x3b, 0x00},{0x33, 0x02},
{0x37, 0x02},{0x38, 0x13},{0x39,0xf0},{0x6c, 0x40},{0x6d, 0x30},
{0x6e, 0x4b},{0x6f, 0x60},{0x70,0x70},{0x71, 0x70},{0x72, 0x70},
{0x73, 0x70},{0x74, 0x60},
{0x75, 0x60},{0x76, 0x50},{0x77,0x48},{0x78, 0x3a},{0x79, 0x2e},
{0x7a, 0x28},{0x7b, 0x22},{0x7c,0x04},{0x7d, 0x07},{0x7e, 0x10},
{0x7f, 0x28},{0x80, 0x36},{0x81,0x44},{0x82, 0x52},{0x83, 0x60},
{0x84, 0x6c},{0x85, 0x78},{0x86,0x8c},{0x87, 0x9e},{0x88, 0xbb},
{0x89, 0xd2},{0x8a, 0xe6},{0x0f,0x4f},{0x3c, 0x40},{0x14, 0xca},
{0x42, 0x89},{0x24, 0x78},{0x25,0x68},{0x26, 0xd4},{0x27, 0x90},
{0x2a, 0x00},{0x2b, 0x00},{0x3d,0x80},{0x41, 0x00},{0x60, 0x8d},
}
},
//////////////////////////////////////////////////////////////////////////
// Omnivision OV9640 Camera 320x240 Mode (QVGA) in "Pass Through Mode"
//////////////////////////////////////////////////////////////////////////
{
/* frame width */ 320,
/* frame heigth */ 240,
/* camera name */ L"Omnivision",
/* camera mode */ L"raw_QVGA",
/* Cmos output format */ CMOS_RAW,
/* Resolution Format */ RAW_QVGA,
/* DPS mode */ CIM_CONFIG_RAW,
/* Bayer Mode */ CIM_CONFIG_BGGR,
/* dbdma channel */ 1,
/* Device Address */ 0x30,
/* No of Sub Register */ 54,
{
{0x12, 0x80},{0x12, 0x15},{0x11,0x83},{0x0c, 0x04},{0x0d, 0xc0},
{0x3b, 0x00},{0x33, 0x02},
{0x37, 0x02},{0x38, 0x13},{0x39,0xf0},{0x6c, 0x40},{0x6d, 0x30},
{0x6e, 0x4b},{0x6f, 0x60},{0x70,0x70},{0x71, 0x70},{0x72, 0x70},
{0x73, 0x70},{0x74, 0x60},
{0x75, 0x60},{0x76, 0x50},{0x77,0x48},{0x78, 0x3a},{0x79, 0x2e},
{0x7a, 0x28},{0x7b, 0x22},{0x7c,0x04},{0x7d, 0x07},{0x7e, 0x10},
{0x7f, 0x28},{0x80, 0x36},{0x81,0x44},{0x82, 0x52},{0x83, 0x60},
{0x84, 0x6c},{0x85, 0x78},{0x86,0x8c},{0x87, 0x9e},{0x88, 0xbb},
{0x89, 0xd2},{0x8a, 0xe6},{0x0f,0x4f},{0x3c, 0x40},{0x14, 0xca},
{0x42, 0x89},{0x24, 0x78},{0x25,0x68},{0x26, 0xd4},{0x27, 0x90},
{0x2a, 0x00},{0x2b, 0x00},{0x3d,0x80},{0x41, 0x00},{0x60, 0x8d},
}
},
//////////////////////////////////////////////////////////////////////////
// Omnivision OV9640 Camera 176x144 QCIF Mode "Pass Through Mode"
//////////////////////////////////////////////////////////////////////////
{
/* frame width */ 176,
/* frame heigth */ 144,
/* camera name */ L"Omnivision",
/* camera mode */ L"raw_QCIF",
/* Cmos output format */ CMOS_RAW,
/* Resolution Format */ RAW_QCIF,
/* DPS mode */ CIM_CONFIG_RAW,
/* Bayer Mode */ CIM_CONFIG_BGGR,
/* dbdma channel */ 1,
/* Device Address */ 0x30,
/* No of Sub Register */ 54,
{
{0x12, 0x80},{0x12, 0x0D},{0x11,0x80},{0x0c, 0x04},{0x0d, 0xc0},
{0x3b, 0x00},{0x33, 0x02},
{0x37, 0x02},{0x38, 0x13},{0x39,0xf0},{0x6c, 0x40},{0x6d, 0x30},
{0x6e, 0x4b},{0x6f, 0x60},{0x70,0x70},{0x71, 0x70},{0x72, 0x70},
{0x73, 0x70},{0x74, 0x60},
{0x75, 0x60},{0x76, 0x50},{0x77,0x48},{0x78, 0x3a},{0x79, 0x2e},
{0x7a, 0x28},{0x7b, 0x22},{0x7c,0x04},{0x7d, 0x07},{0x7e, 0x10},
{0x7f, 0x28},{0x80, 0x36},{0x81,0x44},{0x82, 0x52},{0x83, 0x60},
{0x84, 0x6c},{0x85, 0x78},{0x86,0x8c},{0x87, 0x9e},{0x88, 0xbb},
{0x89, 0xd2},{0x8a, 0xe6},{0x0f,0x6f},{0x3c, 0x60},{0x14, 0xca},
{0x42, 0x89},{0x24, 0x78},{0x25,0x68},{0x26, 0xd4},{0x27, 0x90},
{0x2a, 0x00},{0x2b, 0x00},{0x3d,0x80},{0x41, 0x00},{0x60, 0x8d},
}
},
//////////////////////////////////////////////////////////////////////////
// Omnivision OV9640 Camera 1280x960 Mode (SXGA) in BAYER Mode (Planar)
//////////////////////////////////////////////////////////////////////////
{
/* frame width */ 1280,
/* frame heigth */ 960,
/* camera name */ L"Omnivision",
/* camera mode */ L"bayer_SXGA",
/* Cmos output format */ CMOS_RAW,
/* Resolution Format */ BAYER_SXGA,
/* DPS mode */ CIM_CONFIG_BAYER,
/* Bayer Mode */ CIM_CONFIG_BGGR,
/* dbdma channel */ 3,
/* Device Address */ 0x30,
/* No of Sub Register */ 50,
{
{0x12, 0x80},{0x12, 0x05},{0x11,0x80},{0x3b, 0x00},{0x33, 0x02},
{0x37, 0x02},{0x38, 0x13},{0x39,0xf0},{0x6c, 0x40},{0x6d, 0x30},
{0x6e, 0x4b},{0x6f, 0x60},{0x70,0x70},{0x71, 0x70},{0x74, 0x60},
{0x75, 0x60},{0x76, 0x50},{0x77,0x48},{0x78, 0x3a},{0x79, 0x2e},
{0x7a, 0x2a},{0x7b, 0x22},{0x7c,0x04},{0x7d, 0x07},{0x7e, 0x10},
{0x7f, 0x28},{0x80, 0x36},{0x81,0x44},{0x82, 0x52},{0x83, 0x60},
{0x84, 0x6c},{0x85, 0x78},{0x86,0x8c},{0x87, 0x9e},{0x88, 0xbb},
{0x89, 0xd2},{0x8a, 0xe6},{0x0f,0x4f},{0x3c, 0x40},{0x14, 0xca},
{0x42, 0x89},{0x24, 0x78},{0x25,0x68},{0x26, 0xd4},{0x27, 0x90},
{0x2a, 0x00},{0x2b, 0x00},{0x3d,0x80},{0x41, 0x00},{0x60, 0x8d},
}
},
//////////////////////////////////////////////////////////////////////////
// Omnivision OV9640 Camera 640x480 Mode (VGA) in BAYER Mode (Planar)
//////////////////////////////////////////////////////////////////////////
{
/* frame width */ 640,
/* frame heigth */ 480,
/* camera name */ L"Omnivision",
/* camera mode */ L"bayer_VGA",
/* Cmos output format */ CMOS_RAW,
/* Resolution Format */ BAYER_VGA,
/* DPS mode */ CIM_CONFIG_BAYER,
/* Bayer Mode */ CIM_CONFIG_BGGR,
/* dbdma channel */ 3,
/* Device Address */ 0x30,
/* No of Sub Register */ 54,
{
{0x12, 0x80},{0x12, 0x45},{0x11,0x81},{0x0c, 0x04},{0x0d, 0x40},
{0x3b, 0x00},{0x33, 0x02},
{0x37, 0x02},{0x38, 0x13},{0x39,0xf0},{0x6c, 0x40},{0x6d, 0x30},
{0x6e, 0x4b},{0x6f, 0x60},{0x70,0x70},{0x71, 0x70},{0x72, 0x70},
{0x73, 0x70},{0x74, 0x60},
{0x75, 0x60},{0x76, 0x50},{0x77,0x48},{0x78, 0x3a},{0x79, 0x2e},
{0x7a, 0x28},{0x7b, 0x22},{0x7c,0x04},{0x7d, 0x07},{0x7e, 0x2e},
{0x7f, 0x28},{0x80, 0x36},{0x81,0x44},{0x82, 0x52},{0x83, 0x60},
{0x84, 0x6c},{0x85, 0x78},{0x86,0x8c},{0x87, 0x9e},{0x88, 0xbb},
{0x89, 0xd2},{0x8a, 0xe6},{0x0f,0x4f},{0x3c, 0x40},{0x14, 0xca},
{0x42, 0x89},{0x24, 0x78},{0x25,0x68},{0x26, 0xd4},{0x27, 0x90},
{0x2a, 0x00},{0x2b, 0x00},{0x3d,0x80},{0x41, 0x00},{0x60, 0x8d},
}
},
//////////////////////////////////////////////////////////////////////////
// Omnivision OV9640 Camera 352x288 CIF Mode in BAYER Mode (Planar)
//////////////////////////////////////////////////////////////////////////
{
/* frame width */ 352,
/* frame heigth */ 288,
/* camera name */ L"Omnivision",
/* camera mode */ L"bayer_CIF",
/* Cmos output format */ CMOS_RAW,
/* Resolution Format */ BAYER_CIF,
/* DPS mode */ CIM_CONFIG_BAYER,
/* Bayer Mode */ CIM_CONFIG_BGGR,
/* dbdma channel */ 3,
/* Device Address */ 0x30,
/* No of Sub Register */ 54,
{
{0x12, 0x80},{0x12, 0x25},{0x11,0x80},{0x0c, 0x04},{0x0d, 0x40},
{0x3b, 0x00},{0x33, 0x02},
{0x37, 0x02},{0x38, 0x13},{0x39,0xf0},{0x6c, 0x40},{0x6d, 0x30},
{0x6e, 0x4b},{0x6f, 0x60},{0x70,0x70},{0x71, 0x70},{0x72, 0x70},
{0x73, 0x70},{0x74, 0x60},
{0x75, 0x60},{0x76, 0x50},{0x77,0x48},{0x78, 0x3a},{0x79, 0x2e},
{0x7a, 0x28},{0x7b, 0x22},{0x7c,0x04},{0x7d, 0x07},{0x7e, 0x10},
{0x7f, 0x28},{0x80, 0x36},{0x81,0x44},{0x82, 0x52},{0x83, 0x60},
{0x84, 0x6c},{0x85, 0x78},{0x86,0x8c},{0x87, 0x9e},{0x88, 0xbb},
{0x89, 0xd2},{0x8a, 0xe6},{0x0f,0x4f},{0x3c, 0x40},{0x14, 0xca},
{0x42, 0x89},{0x24, 0x78},{0x25,0x68},{0x26, 0xd4},{0x27, 0x90},
{0x2a, 0x00},{0x2b, 0x00},{0x3d,0x80},{0x41, 0x00},{0x60, 0x8d},
}
},
//////////////////////////////////////////////////////////////////////////
// Omnivision OV9640 Camera 320x240 Mode (QVGA) in BAYER Mode (Planar)
//////////////////////////////////////////////////////////////////////////
{
/* frame width */ 320,
/* frame heigth */ 240,
/* camera name */ L"Omnivision",
/* camera mode */ L"bayer_QVGA",
/* Cmos output format */ CMOS_RAW,
/* Resolution Format */ BAYER_QVGA,
/* DPS mode */ CIM_CONFIG_BAYER,
/* Bayer Mode */ CIM_CONFIG_BGGR,
/* dbdma channel */ 3,
/* Device Address */ 0x30,
/* No of Sub Register */ 54,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -